feat: add normalized min-sum to density evolution engine
Thread cn_mode and alpha parameters through the entire DE pipeline: de_cn_update_vectorized(), density_evolution_step(), run_de(), compute_threshold(), and compute_threshold_for_profile(). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -249,3 +249,35 @@ class TestNormalizedMinSum:
|
||||
assert result_default == result_explicit, (
|
||||
f"Default and explicit offset should match: {result_default} vs {result_explicit}"
|
||||
)
|
||||
|
||||
|
||||
class TestNormalizedMinSumDE:
|
||||
"""Tests for normalized min-sum in the density evolution engine."""
|
||||
|
||||
def test_de_normalized_converges(self):
|
||||
"""DE at lam_s=10 with normalized mode should converge."""
|
||||
from density_evolution import run_de, ORIGINAL_STAIRCASE_PROFILE
|
||||
np.random.seed(42)
|
||||
converged, error_frac = run_de(
|
||||
ORIGINAL_STAIRCASE_PROFILE, lam_s=10.0, lam_b=0.1,
|
||||
z_pop=10000, max_iter=50,
|
||||
cn_mode='normalized', alpha=0.75
|
||||
)
|
||||
assert converged, f"DE normalized should converge at lam_s=10, error_frac={error_frac}"
|
||||
|
||||
def test_de_normalized_threshold_different(self):
|
||||
"""Normalized and offset modes should produce different thresholds."""
|
||||
from density_evolution import compute_threshold, ORIGINAL_STAIRCASE_PROFILE
|
||||
np.random.seed(42)
|
||||
thresh_offset = compute_threshold(
|
||||
ORIGINAL_STAIRCASE_PROFILE, lam_b=0.1, z_pop=10000, tol=0.5,
|
||||
cn_mode='offset'
|
||||
)
|
||||
np.random.seed(42)
|
||||
thresh_norm = compute_threshold(
|
||||
ORIGINAL_STAIRCASE_PROFILE, lam_b=0.1, z_pop=10000, tol=0.5,
|
||||
cn_mode='normalized', alpha=0.75
|
||||
)
|
||||
assert thresh_norm != thresh_offset, (
|
||||
f"Thresholds should differ: offset={thresh_offset}, normalized={thresh_norm}"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user