Function wilson_ci_from_proportion
pub fn wilson_ci_from_proportion(p_hat: f64, n: u32) -> (f64, f64)Expand description
Wilson score 95% confidence interval around an already-computed proportion
p_hat observed over a pool of n.
Unlike wilson_ci, the point estimate is supplied directly rather than
formed from an integer k / n. This is the entry point the corpus-percentile
lens uses: the reported percentile is a midpoint-rank (or breakpoint-
interpolated) empirical-CDF estimate, not an integer success count, and the
interval must wrap that SAME estimate so low <= p_hat <= high holds. n is
the honest pool size behind the estimate — the number of corpus repos in a
repo-level pool, or a language’s pooled per-function sample count.
Returns (low, high) clamped to [0.0, 1.0]; (0.0, 0.0) when n = 0.
p_hat is assumed in [0.0, 1.0] (every caller’s estimator is a percentile),
which keeps the radicand non-negative so the result is never NaN. Standard
Wilson score interval (Wilson 1927); z = 1.96 for 95% coverage.