public final class BoundsOnBinomialProportions extends Object
This class computes an approximation to the ClopperPearson confidence interval for a binomial proportion. Exact ClopperPearson intervals are strictly conservative, but these approximations are not.
The main inputs are numbers n and k, which are not the same as other things that are called n and k in our sketching library. There is also a third parameter, numStdDev, that specifies the desired confidence level.
Alternatively, consider a coin with unknown heads probability p. Where n is the number of independent flips of that coin, and k is the number of times that the coin comes up heads during a given batch of n flips. This class computes a frequentist confidence interval [lowerBoundOnP, upperBoundOnP] for the unknown p.
Conceptually, the desired confidence level is specified by a tail probability delta.
Ideally, over a large ensemble of independent batches of trials, the fraction of batches in which the true p lies below lowerBoundOnP would be at most delta, and the fraction of batches in which the true p lies above upperBoundOnP would also be at most delta.
Setting aside the philosophical difficulties attaching to that statement, it isn't quite true because we are approximating the ClopperPearson interval.
Finally, we point out that in this class's interface, the confidence parameter delta is not specified directly, but rather through a "number of standard deviations" numStdDev. The library effectively converts that to a delta via delta = normalCDF (1.0 * numStdDev).
It is perhaps worth emphasizing that the library is NOT merely adding and subtracting numStdDev standard deviations to the estimate. It is doing something better, that to some extent accounts for the fact that the binomial distribution has a nongaussian shape.
In particular, it is using an approximation to the inverse of the incomplete beta function that appears as formula 26.5.22 on page 945 of the "Handbook of Mathematical Functions" by Abramowitz and Stegun.
Modifier and Type  Method and Description 

static double 
approximateLowerBoundOnP(long n,
long k,
double numStdDevs)
Computes lower bound of approximate ClopperPearson confidence interval for a binomial
proportion.

static double 
approximateUpperBoundOnP(long n,
long k,
double numStdDevs)
Computes upper bound of approximate ClopperPearson confidence interval for a binomial
proportion.

static double 
erf(double x)
Computes an approximation to the erf() function.

static double 
estimateUnknownP(long n,
long k)
Computes an estimate of an unknown binomial proportion.

static double 
normalCDF(double x)
Computes an approximation to normalCDF(x).

public static double approximateLowerBoundOnP(long n, long k, double numStdDevs)
Implementation Notes:
The approximateLowerBoundOnP is defined with respect to the right tail of the binomial
distribution.
n
 is the number of trials. Must be nonnegative.k
 is the number of successes. Must be nonnegative, and cannot exceed n.numStdDevs
 the number of standard deviations defining the confidence intervalpublic static double approximateUpperBoundOnP(long n, long k, double numStdDevs)
Implementation Notes:
The approximateUpperBoundOnP is defined with respect to the left tail of the binomial
distribution.
n
 is the number of trials. Must be nonnegative.k
 is the number of successes. Must be nonnegative, and cannot exceed n.numStdDevs
 the number of standard deviations defining the confidence intervalpublic static double estimateUnknownP(long n, long k)
n
 is the number of trials. Must be nonnegative.k
 is the number of successes. Must be nonnegative, and cannot exceed n.public static double erf(double x)
x
 is the input to the erf functionpublic static double normalCDF(double x)
x
 is the input to the normalCDF functionCopyright © 2015–2020 The Apache Software Foundation. All rights reserved.