Package org.hipparchus.stat.interval
Class BinomialProportion
- java.lang.Object
-
- org.hipparchus.stat.interval.BinomialProportion
-
public class BinomialProportion extends Object
Utility methods to generate confidence intervals for a binomial proportion.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ConfidenceInterval
getAgrestiCoullInterval(int numberOfTrials, double probabilityOfSuccess, double confidenceLevel)
Create an Agresti-Coull binomial confidence interval for the true probability of success of an unknown binomial distribution with the given observed number of trials, probability of success and confidence level.static ConfidenceInterval
getClopperPearsonInterval(int numberOfTrials, double probabilityOfSuccess, double confidenceLevel)
Create a Clopper-Pearson binomial confidence interval for the true probability of success of an unknown binomial distribution with the given observed number of trials, probability of success and confidence level.static ConfidenceInterval
getNormalApproximationInterval(int numberOfTrials, double probabilityOfSuccess, double confidenceLevel)
Create a binomial confidence interval using normal approximation for the true probability of success of an unknown binomial distribution with the given observed number of trials, probability of success and confidence level.static ConfidenceInterval
getWilsonScoreInterval(int numberOfTrials, double probabilityOfSuccess, double confidenceLevel)
Create an Wilson score binomial confidence interval for the true probability of success of an unknown binomial distribution with the given observed number of trials, probability of success and confidence level.
-
-
-
Method Detail
-
getAgrestiCoullInterval
public static ConfidenceInterval getAgrestiCoullInterval(int numberOfTrials, double probabilityOfSuccess, double confidenceLevel) throws MathIllegalArgumentException
Create an Agresti-Coull binomial confidence interval for the true probability of success of an unknown binomial distribution with the given observed number of trials, probability of success and confidence level.Preconditions:
numberOfTrials
must be positiveprobabilityOfSuccess
must be between 0 and 1 (inclusive)confidenceLevel
must be strictly between 0 and 1 (exclusive)
- Parameters:
numberOfTrials
- number of trialsprobabilityOfSuccess
- observed probability of successconfidenceLevel
- desired probability that the true probability of success falls within the returned interval- Returns:
- Confidence interval containing the probability of success with
probability
confidenceLevel
- Throws:
MathIllegalArgumentException
- ifnumberOfTrials <= 0
.MathIllegalArgumentException
- ifprobabilityOfSuccess
is not in the interval [0, 1].MathIllegalArgumentException
- ifconfidenceLevel
is not in the interval (0, 1).- See Also:
- Agresti-Coull interval (Wikipedia)
-
getClopperPearsonInterval
public static ConfidenceInterval getClopperPearsonInterval(int numberOfTrials, double probabilityOfSuccess, double confidenceLevel) throws MathIllegalArgumentException
Create a Clopper-Pearson binomial confidence interval for the true probability of success of an unknown binomial distribution with the given observed number of trials, probability of success and confidence level.Preconditions:
numberOfTrials
must be positiveprobabilityOfSuccess
must be between 0 and 1 (inclusive)confidenceLevel
must be strictly between 0 and 1 (exclusive)
- Parameters:
numberOfTrials
- number of trialsprobabilityOfSuccess
- observed probability of successconfidenceLevel
- desired probability that the true probability of success falls within the returned interval- Returns:
- Confidence interval containing the probability of success with
probability
confidenceLevel
- Throws:
MathIllegalArgumentException
- ifnumberOfTrials <= 0
.MathIllegalArgumentException
- ifprobabilityOfSuccess
is not in the interval [0, 1].MathIllegalArgumentException
- ifconfidenceLevel
is not in the interval (0, 1).- See Also:
- Clopper-Pearson interval (Wikipedia)
-
getNormalApproximationInterval
public static ConfidenceInterval getNormalApproximationInterval(int numberOfTrials, double probabilityOfSuccess, double confidenceLevel) throws MathIllegalArgumentException
Create a binomial confidence interval using normal approximation for the true probability of success of an unknown binomial distribution with the given observed number of trials, probability of success and confidence level.Preconditions:
numberOfTrials
must be positiveprobabilityOfSuccess
must be between 0 and 1 (inclusive)confidenceLevel
must be strictly between 0 and 1 (exclusive)
- Parameters:
numberOfTrials
- number of trialsprobabilityOfSuccess
- observed probability of successconfidenceLevel
- desired probability that the true probability of success falls within the returned interval- Returns:
- Confidence interval containing the probability of success with
probability
confidenceLevel
- Throws:
MathIllegalArgumentException
- ifnumberOfTrials <= 0
.MathIllegalArgumentException
- ifprobabilityOfSuccess
is not in the interval [0, 1].MathIllegalArgumentException
- ifconfidenceLevel
is not in the interval (0, 1).- See Also:
- Normal approximation interval (Wikipedia)
-
getWilsonScoreInterval
public static ConfidenceInterval getWilsonScoreInterval(int numberOfTrials, double probabilityOfSuccess, double confidenceLevel) throws MathIllegalArgumentException
Create an Wilson score binomial confidence interval for the true probability of success of an unknown binomial distribution with the given observed number of trials, probability of success and confidence level.Preconditions:
numberOfTrials
must be positiveprobabilityOfSuccess
must be between 0 and 1 (inclusive)confidenceLevel
must be strictly between 0 and 1 (exclusive)
- Parameters:
numberOfTrials
- number of trialsprobabilityOfSuccess
- observed probability of successconfidenceLevel
- desired probability that the true probability of success falls within the returned interval- Returns:
- Confidence interval containing the probability of success with
probability
confidenceLevel
- Throws:
MathIllegalArgumentException
- ifnumberOfTrials <= 0
.MathIllegalArgumentException
- ifprobabilityOfSuccess
is not in the interval [0, 1].MathIllegalArgumentException
- ifconfidenceLevel
is not in the interval (0, 1).- See Also:
- Wilson score interval (Wikipedia)
-
-