This package computes confidence intervals for the probability of success parameter,
The documentation for the package can be found at: https://tri-ml.github.io/binomial_cis.
Install the package with pip:
pip install binomial_cis
This package constructs optimal confidence intervals for the probability of success parameter,
Given user specified miscoverage rate (
- achieves exact desired coverage:
$\mathbb{P}[\underline{p} \le p] = 1-\alpha$ , -
$[\underline{p}, 1]$ is uniformly most accurate, - achieves exact desired maximum expected shortage:
$\max_p \ \mathbb{E}_p[\max (p - \underline{p}, 0)] = \text{MES}$ , - uses the minimum number of samples
$n$ to achieve requirements 1,2,3.
Given user specified miscoverage rate (
- achieves exact desired coverage:
$\mathbb{P}[p \le \overline{p}] = 1-\alpha$ , -
$[0, \overline{p}]$ is uniformly most accurate, - achieves exact desired maximum expected excess:
$\max_p \ \mathbb{E}_p[\max (\overline{p} - p, 0)] = \text{MEE}$ , - uses the minimum number of samples
$n$ to achieve requirements 1,2,3.
Given the user specified miscoverage rate (
- achieves exact desired coverage:
$\mathbb{P}[\underline{p} \le p \le \overline{p}] = 1-\alpha$ , -
$[\underline{p}, \overline{p}]$ is uniformly most accurate unbiased, - achieves exact desired maximum expected width:
$\max_p \ \mathbb{E}_p[\overline{p} - \underline{p}] = \text{MEW}$ , - uses the minimum number of samples
$n$ to achieve requirements 1,2,3.
Find a lower bound on
from binomial_cis import binom_ci
k = 5 # number of successes
n = 10 # number of trials
alpha = 0.05 # miscoverage probability
lb = binom_ci(k, n, alpha, 'lb')
Find maximum expected shortage given miscoverage rate and number of samples:
from binomial_cis import max_expected_shortage
mes_ub, mes_lb, p_lb, num_iters = max_expected_shortage(alpha, n, tol=1e-3)
Find an upper bound on
from binomial_cis import binom_ci
k = 5 # number of successes
n = 10 # number of trials
alpha = 0.05 # miscoverage probability
ub = binom_ci(k, n, alpha, 'ub')
Find maximum expected excess given miscoverage rate and number of samples:
from binomial_cis import max_expected_excess
mee_ub, mee_lb, p_lb, num_iters = max_expected_excess(alpha, n, tol=1e-3)
Find simultaneous lower and upper bounds on
from binomial_cis import binom_ci
k = 5 # number of successes
n = 10 # number of trials
alpha = 0.05 # miscoverage probability
lb, ub = binom_ci(k, n, alpha, 'lb,ub')
Find maximum expected width given miscoverage rate and number of samples:
from binomial_cis import max_expected_width
mew_ub, mew_lb, p_lb, num_iters = max_expected_width(alpha, n, tol=1e-3)