Enum BinomialConfidenceInterval
- java.lang.Object
-
- java.lang.Enum<BinomialConfidenceInterval>
-
- org.apache.commons.statistics.interval.BinomialConfidenceInterval
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<BinomialConfidenceInterval>
public enum BinomialConfidenceInterval extends java.lang.Enum<BinomialConfidenceInterval>
Generate confidence intervals for a binomial proportion.Note: To avoid overshoot, the confidence intervals are clipped to be in the
[0, 1]interval in the case of thenormal approximationandAgresti-Coullmethods.- Since:
- 1.2
- See Also:
- Binomial proportion confidence interval (Wikipedia)
-
-
Enum Constant Summary
Enum Constants Enum Constant Description AGRESTI_COULLImplements the Agresti-Coull method for creating a binomial proportion confidence interval.CLOPPER_PEARSONImplements the Clopper-Pearson method for creating a binomial proportion confidence interval.JEFFREYSImplements the Jeffreys method for creating a binomial proportion confidence interval.NORMAL_APPROXIMATIONImplements the normal approximation method for creating a binomial proportion confidence interval.WILSON_SCOREImplements the Wilson score method for creating a binomial proportion confidence interval.
-
Field Summary
Fields Modifier and Type Field Description (package private) static NormalDistributionNORMAL_DISTRIBUTIONThe standard normal distribution.
-
Constructor Summary
Constructors Modifier Constructor Description privateBinomialConfidenceInterval()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description (package private) static doubleclip(double p)Clip the probability to [0, 1].(package private) abstract Intervalcreate(int n, int x, double alpha)Create a confidence interval for the true probability of success of an unknown binomial distribution with the given observed number of trials, successes and error rate.IntervalfromErrorRate(int numberOfTrials, int numberOfSuccesses, double alpha)Create a confidence interval for the true probability of success of an unknown binomial distribution with the given observed number of trials, successes and error rate.static BinomialConfidenceIntervalvalueOf(java.lang.String name)Returns the enum constant of this type with the specified name.static BinomialConfidenceInterval[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
NORMAL_APPROXIMATION
public static final BinomialConfidenceInterval NORMAL_APPROXIMATION
Implements the normal approximation method for creating a binomial proportion confidence interval.This method clips the confidence interval to be in
[0, 1].
-
WILSON_SCORE
public static final BinomialConfidenceInterval WILSON_SCORE
Implements the Wilson score method for creating a binomial proportion confidence interval.
-
JEFFREYS
public static final BinomialConfidenceInterval JEFFREYS
Implements the Jeffreys method for creating a binomial proportion confidence interval.In order to avoid the coverage probability tending to zero when
ptends towards 0 or 1, whenx = 0the lower limit is set to 0, and whenx = nthe upper limit is set to 1.- See Also:
- Jeffreys interval (Wikipedia)
-
CLOPPER_PEARSON
public static final BinomialConfidenceInterval CLOPPER_PEARSON
Implements the Clopper-Pearson method for creating a binomial proportion confidence interval.- See Also:
- Clopper-Pearson interval (Wikipedia)
-
AGRESTI_COULL
public static final BinomialConfidenceInterval AGRESTI_COULL
Implements the Agresti-Coull method for creating a binomial proportion confidence interval.This method clips the confidence interval to be in
[0, 1].- See Also:
- Agresti-Coull interval (Wikipedia)
-
-
Field Detail
-
NORMAL_DISTRIBUTION
static final NormalDistribution NORMAL_DISTRIBUTION
The standard normal distribution.
-
-
Method Detail
-
values
public static BinomialConfidenceInterval[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (BinomialConfidenceInterval c : BinomialConfidenceInterval.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static BinomialConfidenceInterval valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException- if this enum type has no constant with the specified namejava.lang.NullPointerException- if the argument is null
-
fromErrorRate
public Interval fromErrorRate(int numberOfTrials, int numberOfSuccesses, double alpha)
Create a confidence interval for the true probability of success of an unknown binomial distribution with the given observed number of trials, successes and error rate.The error rate
alphais related to the confidence level that the interval contains the true probability of success asalpha = 1 - confidence, whereconfidenceis the confidence level in[0, 1]. For example a 95% confidence level is analphaof 0.05.- Parameters:
numberOfTrials- Number of trials.numberOfSuccesses- Number of successes.alpha- Desired error rate that the true probability of success falls outside the returned interval.- Returns:
- Confidence interval containing the probability of success with error rate
alpha - Throws:
java.lang.IllegalArgumentException- ifnumberOfTrials <= 0, ifnumberOfSuccesses < 0, ifnumberOfSuccesses > numberOfTrials, or ifalphais not in the open interval(0, 1).
-
create
abstract Interval create(int n, int x, double alpha)
Create a confidence interval for the true probability of success of an unknown binomial distribution with the given observed number of trials, successes and error rate.- Parameters:
n- Number of trials.x- Number of successes.alpha- Desired error rate.- Returns:
- Confidence interval
-
clip
static double clip(double p)
Clip the probability to [0, 1].- Parameters:
p- Probability.- Returns:
- the probability in [0, 1]
-
-