uvex_transients.utils.stat_utils.clopper_pearson_interval#

uvex_transients.utils.stat_utils.clopper_pearson_interval(k: int, n: int, confidence: float) → tuple[float, float][source]#

Compute the exact (Clopper-Pearson) confidence interval on a binomial proportion.

The interval is central, with probability \((1-C)/2\) in each tail. Its limits are quantiles of Beta distributions, except at the boundaries where they are fixed: the lower limit is 0 for \(k=0\) and the upper limit is 1 for \(k=n\).

Parameters:
  • k (int) – Number of successes, 0 <= k <= n.

  • n (int) – Number of trials. For n = 0 the proportion is unconstrained and the interval is (0, 1).

  • confidence (float) – Confidence level \(C\), in (0, 1).

Returns:

The (lower, upper) limits.

Return type:

tuple of float