Compare three 95%-style intervals for a binomial proportion after observing successes in trials, and compute their exact frequentist coverage. Do not use scipy. For level let satisfy , where ; find it numerically to at least accuracy. Let .
wald_ci(k, n, level=0.95): , clipped to .wilson_ci(k, n, level=0.95): center , half-width , clipped to .jeffreys_ci(k, n, level=0.95): the equal-tailed credible interval of the posterior (Jeffreys prior), i.e. its and quantiles, except that the lower end is when and the upper end is when . Quantiles must be accurate to (for example, the regularized incomplete beta function evaluated by its continued fraction, inverted by bisection).exact_coverage(method, n, theta, level=0.95): method is "wald", "wilson" or "jeffreys". Return , the probability that the interval computed from a fresh sample covers .Return floats; intervals as (lo, hi) tuples.