Skip to content

RareEvents ​

Wilson intervals and the flat, stratified and signed LER estimators

13/13 passed in 115477ms

TestWhat it doesResult
test_clamped_rate_is_display_onlyclamped_rate clips a negative estimate and its interval into [0, 1] and leaves an in-range estimate untouched, so a plot never feeds back into the raw number.✅ pass
test_paired_second_decoder_unbiasedScored on the first decoder's shared stratified batch, a second decoder's LER agrees with its own independent run: the shared allocation moves variance, not bias.✅ pass
test_signed_ci_covers_true_rateThe 95% interval around the signed estimate covers the exact rate near its nominal frequency across 300 seeds.✅ pass
test_signed_ler_unbiased_over_seedsAveraged over 300 seeds the raw signed estimate sits on the exact rate within 1.5 standard errors, while clipping each run first (seed 0 alone draws -0.097) pushes the average over 3 sigma high: the estimate must stay unclipped.✅ pass
test_stderr_matches_observed_spreadOver 300 seeds the mean reported stderr is within 20% of the observed standard deviation of the estimate. Every shot has the same |weight|, so the variance lives in the sign and a binomial bar would be far too small.✅ pass
test_stderr_nonzero_when_no_failureA run with no failures still reports a positive stderr: a noiseless surface memory (Pauli, mwpm) and an undamped amplitude-damping memory (signed, coherent) both give ler 0 with a Wilson-floored bar.✅ pass
test_stratified_pauli_beats_binomialAt small p stratified sampling over-samples the rare high-fault strata, so across seeds it reports a smaller stderr and scatters less than plain sampling at equal shots.✅ pass
test_stratified_stderr_tracks_spreadThe stratified error bar, per-stratum sample spreads in quadrature, tracks the observed scatter of the estimate across 60 seeds on the RX memory.✅ pass
test_stratified_warns_on_dropped_massA shot budget too small to reach every stratum leaves quasiprobability mass unsampled, a bias no error bar shows, so the estimator warns: 8 shots on a coherent memory do, 2000 do not.✅ pass
test_stratify_agrees_with_flatlogical_error_rate(stratify=True) reaches the stratified estimator on Pauli noise (mld, weight-stratified subset sampling) and on non-Pauli noise (mwpm on the RX memory's twirl), and agrees with the flat estimate within error bars.✅ pass
test_wilson_covers_true_rateOn synthetic binomials the 95% Wilson interval covers the true rate near its nominal frequency, the property a naive stderr loses at small k.✅ pass
test_wilson_reduces_to_normal_away_from_boundaryFar from k=0 the Wilson half-width over z matches the normal-approx binomial stderr to 2%: the interval only differs where the normal approximation fails.✅ pass
test_wilson_upper_bound_nonzero_at_zero_failuresZero failures in N shots still carry a positive upper bound: the naive sqrt(p(1-p)/N) collapses to 0 there, the Wilson score interval does not.✅ pass