SPB Git

Repository Public Research preview

test_bootstrap.py 769 B 19 lines python

1import numpy as np23from wp_ai_0001.statistics.bootstrap import cluster_bootstrap_mean, cluster_bootstrap_paired_diff456def test_bootstrap_ci_contains_mean_and_is_deterministic():7    rng = np.random.default_rng(0)8    vals = (rng.random(1000) < 0.7).astype(float)9    clusters = [f"c{i % 50}" for i in range(1000)]10    ci1 = cluster_bootstrap_mean(vals, clusters, n_boot=500, seed=1)11    ci2 = cluster_bootstrap_mean(vals, clusters, n_boot=500, seed=1)12    assert ci1.low <= ci1.estimate <= ci1.high and ci1 == ci2 and ci1.n_clusters == 50131415def test_paired_diff_zero_when_identical():16    vals = np.ones(100)17    ci = cluster_bootstrap_paired_diff(vals, vals, [f"c{i%10}" for i in range(100)], n_boot=100)18    assert ci.estimate == 0 and ci.low == 0 and ci.high == 019
Files main
Menu

Theme