public final class IntervalUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static BinomialConfidenceInterval |
AGRESTI_COULL
Singleton Agresti-Coull instance.
|
private static BinomialConfidenceInterval |
CLOPPER_PEARSON
Singleton Clopper-Pearson instance.
|
private static BinomialConfidenceInterval |
NORMAL_APPROXIMATION
Singleton NormalApproximation instance.
|
private static BinomialConfidenceInterval |
WILSON_SCORE
Singleton Wilson score instance.
|
Modifier | Constructor and Description |
---|---|
private |
IntervalUtils()
Prevent instantiation.
|
Modifier and Type | Method and Description |
---|---|
(package private) static void |
checkParameters(int numberOfTrials,
int numberOfSuccesses,
double confidenceLevel)
Verifies that parameters satisfy preconditions.
|
static ConfidenceInterval |
getAgrestiCoullInterval(int numberOfTrials,
int numberOfSuccesses,
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, successes and confidence level.
|
static ConfidenceInterval |
getClopperPearsonInterval(int numberOfTrials,
int numberOfSuccesses,
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, successes and confidence level.
|
static ConfidenceInterval |
getNormalApproximationInterval(int numberOfTrials,
int numberOfSuccesses,
double confidenceLevel)
Create a binomial confidence interval for the true probability of success
of an unknown binomial distribution with the given observed number of
trials, successes and confidence level using the Normal approximation to
the binomial distribution.
|
static ConfidenceInterval |
getWilsonScoreInterval(int numberOfTrials,
int numberOfSuccesses,
double confidenceLevel)
Create a Wilson score binomial confidence interval for the true
probability of success of an unknown binomial distribution with the given
observed number of trials, successes and confidence level.
|
private static final BinomialConfidenceInterval AGRESTI_COULL
private static final BinomialConfidenceInterval CLOPPER_PEARSON
private static final BinomialConfidenceInterval NORMAL_APPROXIMATION
private static final BinomialConfidenceInterval WILSON_SCORE
public static ConfidenceInterval getAgrestiCoullInterval(int numberOfTrials, int numberOfSuccesses, double confidenceLevel)
numberOfTrials
- number of trialsnumberOfSuccesses
- number of successesconfidenceLevel
- desired probability that the true probability of
success falls within the returned intervalconfidenceLevel
NotStrictlyPositiveException
- if numberOfTrials <= 0
.NotPositiveException
- if numberOfSuccesses < 0
.NumberIsTooLargeException
- if numberOfSuccesses > numberOfTrials
.OutOfRangeException
- if confidenceLevel
is not in the interval (0, 1)
.public static ConfidenceInterval getClopperPearsonInterval(int numberOfTrials, int numberOfSuccesses, double confidenceLevel)
Preconditions:
numberOfTrials
must be positivenumberOfSuccesses
may not exceed numberOfTrials
confidenceLevel
must be strictly between 0 and 1 (exclusive)numberOfTrials
- number of trialsnumberOfSuccesses
- number of successesconfidenceLevel
- desired probability that the true probability of
success falls within the returned intervalconfidenceLevel
NotStrictlyPositiveException
- if numberOfTrials <= 0
.NotPositiveException
- if numberOfSuccesses < 0
.NumberIsTooLargeException
- if numberOfSuccesses > numberOfTrials
.OutOfRangeException
- if confidenceLevel
is not in the interval (0, 1)
.public static ConfidenceInterval getNormalApproximationInterval(int numberOfTrials, int numberOfSuccesses, double confidenceLevel)
numberOfTrials
- number of trialsnumberOfSuccesses
- number of successesconfidenceLevel
- desired probability that the true probability of
success falls within the intervalconfidenceLevel
public static ConfidenceInterval getWilsonScoreInterval(int numberOfTrials, int numberOfSuccesses, double confidenceLevel)
numberOfTrials
- number of trialsnumberOfSuccesses
- number of successesconfidenceLevel
- desired probability that the true probability of
success falls within the returned intervalconfidenceLevel
NotStrictlyPositiveException
- if numberOfTrials <= 0
.NotPositiveException
- if numberOfSuccesses < 0
.NumberIsTooLargeException
- if numberOfSuccesses > numberOfTrials
.OutOfRangeException
- if confidenceLevel
is not in the interval (0, 1)
.static void checkParameters(int numberOfTrials, int numberOfSuccesses, double confidenceLevel)
numberOfTrials
- number of trials (must be positive)numberOfSuccesses
- number of successes (must not exceed numberOfTrials)confidenceLevel
- confidence level (must be strictly between 0 and 1)NotStrictlyPositiveException
- if numberOfTrials <= 0
.NotPositiveException
- if numberOfSuccesses < 0
.NumberIsTooLargeException
- if numberOfSuccesses > numberOfTrials
.OutOfRangeException
- if confidenceLevel
is not in the interval (0, 1)
.Copyright (c) 2003-2014 Apache Software Foundation