of repeated draws of a binomial distribution. In this case, the underlying distribution would be the hypergeometric distribution. The interval boundaries are easily computed with numerical methods functions like qbeta in R and scipy.stats.beta.ppf in Python. from scipy.stats import beta k = 20 n = 400 alpha = 0.05 p_u, p_o = beta.ppf([alpha/2, 1 - alpha/2], [k, k + 1], [n - k + 1, n - k]) Agresti–Coull interval The Agresti–Coull interval is also another approximate binomial confidence interval. Given successes in trials, define and Then, a confidence interval for is given by where is the quantile of a standard normal distribution, as before (for example, a 95% confidence interval requires , thereby producing ). According to Brown, Cai, and DasGupta, taking instead of 1.96 produces the "add 2 successes and 2 failures" interval previously described by Agresti and Coull. This interval can be summarised as employing the centre-point adjustment, , of the Wilson score interval, and then applying the Normal approximation to this point. Arcsine transformation The arcsine transformation has the effect of pulling out the ends of the distribution. While it can stabilize the variance (and thus confidence intervals) of proportion data, its use has been criticized in several contexts. Let X be the number of successes in n trials and let p = X/n. The variance of p is Using the arc sine transform the variance of the arcsine of p1/2 is So, the confidence interval itself has the following form: where is the quantile of a standard normal distribution. This method may be used to estimate the variance of p but its use is problematic when p is close to 0 or 1. ta transform Let p be the proportion of successes. For 0 ≤ a ≤ 2, This family is a generalisation of the logit transform which is a special case with a = 1 and can be used to transform a proportional data distribution to an approximately normal distribution. The parameter a has to be estimated for the data set. Rule of three — for when no successes are observed The rule of three is used to provide a simple way of stating an approximate 95% confidence interval for p, in the special case that no successes () have been observed. The interval is . By symmetry, one could expect for only successes (), the interval is . Comparison and discussion There are