feat(sobol): the number of classes with draws, for the expectation without an effect

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Kjell Tore Guttormsen 2026-11-13 18:47:03 +01:00
commit 925df404a0
Signed by: ktg
SSH key fingerprint: SHA256:JakMjO6FTBBzN0Bhfj9saOoEjaFxlSdYuZQQpM/lF9Q
2 changed files with 20 additions and 5 deletions

View file

@ -251,4 +251,9 @@ def test_forventningen_uten_virkning_er_om_lag_M_minus_1_over_N_minus_1() -> Non
indekser = [sobol.indeks(rng.normal(size=N).tolist(), y) for _ in range(300)]
snitt = math.fsum(i for i in indekser if i is not None) / 300
assert sobol.forventning_uten_virkning(N) == 9 / 399
# a quantity with few values has fewer classes with draws, and a lower expectation
x = [0.0] * 100 + [1.0] * 100 + [2.0] * 200
assert sobol.klasser_med_trekninger(x) == 3
assert sobol.klasser_med_trekninger(rng.normal(size=N).tolist()) == 10
assert sobol.forventning_uten_virkning(N, 3) == 2 / 399
assert snitt == pytest.approx(9 / 399, abs=0.002)