Top Description Fields Constructors Methods
org.apache.commons.math3.stat.interval

public final Class IntervalUtils

extends Object
Class Inheritance
Imports
org.apache.commons.math3.exception.NotPositiveException, .NotStrictlyPositiveException, .NumberIsTooLargeException, .OutOfRangeException, org.apache.commons.math3.exception.util.LocalizedFormats

Factory methods to generate confidence intervals for a binomial proportion. The supported methods are:
Since
3.3

Field Summary

Modifier and TypeField and Description
private static final BinomialConfidenceInterval
AGRESTI_COULL

Singleton Agresti-Coull instance.

private static final BinomialConfidenceInterval
CLOPPER_PEARSON

Singleton Clopper-Pearson instance.

private static final BinomialConfidenceInterval
NORMAL_APPROXIMATION

Singleton NormalApproximation instance.

private static final BinomialConfidenceInterval
WILSON_SCORE

Singleton Wilson score instance.

Constructor Summary

AccessConstructor and Description
private
IntervalUtils()

Prevent instantiation.

Method Summary

Modifier and TypeMethod and Description
pack-priv static void
checkParameters(int
number of trials (must be positive)
numberOfTrials
,
int
number of successes (must not exceed numberOfTrials)
numberOfSuccesses
,
double
confidence level (must be strictly between 0 and 1)
confidenceLevel
)

Verifies that parameters satisfy preconditions.

public static ConfidenceInterval

Returns:

Confidence interval containing the probability of success with probability confidenceLevel
getAgrestiCoullInterval
(int
number of trials
numberOfTrials
,
int
number of successes
numberOfSuccesses
,
double
desired probability that the true probability of success falls within the returned interval
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.

public static ConfidenceInterval

Returns:

Confidence interval containing the probability of success with probability confidenceLevel
getClopperPearsonInterval
(int
number of trials
numberOfTrials
,
int
number of successes
numberOfSuccesses
,
double
desired probability that the true probability of success falls within the returned interval
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.

public static ConfidenceInterval

Returns:

Confidence interval containing the probability of success with probability confidenceLevel
getNormalApproximationInterval
(int
number of trials
numberOfTrials
,
int
number of successes
numberOfSuccesses
,
double
desired probability that the true probability of success falls within the interval
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.

public static ConfidenceInterval

Returns:

Confidence interval containing the probability of success with probability confidenceLevel
getWilsonScoreInterval
(int
number of trials
numberOfTrials
,
int
number of successes
numberOfSuccesses
,
double
desired probability that the true probability of success falls within the returned interval
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.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

AGRESTI_COULLback to summary
private static final BinomialConfidenceInterval AGRESTI_COULL

Singleton Agresti-Coull instance.

CLOPPER_PEARSONback to summary
private static final BinomialConfidenceInterval CLOPPER_PEARSON

Singleton Clopper-Pearson instance.

NORMAL_APPROXIMATIONback to summary
private static final BinomialConfidenceInterval NORMAL_APPROXIMATION

Singleton NormalApproximation instance.

WILSON_SCOREback to summary
private static final BinomialConfidenceInterval WILSON_SCORE

Singleton Wilson score instance.

Constructor Detail

IntervalUtilsback to summary
private IntervalUtils()

Prevent instantiation.

Method Detail

checkParametersback to summary
pack-priv static void checkParameters(int numberOfTrials, int numberOfSuccesses, double confidenceLevel)

Verifies that parameters satisfy preconditions.

Parameters
numberOfTrials:int

number of trials (must be positive)

numberOfSuccesses:int

number of successes (must not exceed numberOfTrials)

confidenceLevel:double

confidence level (must be strictly between 0 and 1)

Exceptions
NotStrictlyPositiveException:
if numberOfTrials <= 0.
NotPositiveException:
if numberOfSuccesses < 0.
NumberIsTooLargeException:
if numberOfSuccesses > numberOfTrials.
OutOfRangeException:
if confidenceLevel is not in the interval (0, 1).
getAgrestiCoullIntervalback to summary
public 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.

Parameters
numberOfTrials:int

number of trials

numberOfSuccesses:int

number of successes

confidenceLevel:double

desired probability that the true probability of success falls within the returned interval

Returns:ConfidenceInterval

Confidence interval containing the probability of success with probability confidenceLevel

Exceptions
NotStrictlyPositiveException:
if numberOfTrials <= 0.
NotPositiveException:
if numberOfSuccesses < 0.
NumberIsTooLargeException:
if numberOfSuccesses > numberOfTrials.
OutOfRangeException:
if confidenceLevel is not in the interval (0, 1).
getClopperPearsonIntervalback to summary
public 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.

Preconditions:

  • numberOfTrials must be positive
  • numberOfSuccesses may not exceed numberOfTrials
  • confidenceLevel must be strictly between 0 and 1 (exclusive)

Parameters
numberOfTrials:int

number of trials

numberOfSuccesses:int

number of successes

confidenceLevel:double

desired probability that the true probability of success falls within the returned interval

Returns:ConfidenceInterval

Confidence interval containing the probability of success with probability confidenceLevel

Exceptions
NotStrictlyPositiveException:
if numberOfTrials <= 0.
NotPositiveException:
if numberOfSuccesses < 0.
NumberIsTooLargeException:
if numberOfSuccesses > numberOfTrials.
OutOfRangeException:
if confidenceLevel is not in the interval (0, 1).
getNormalApproximationIntervalback to summary
public 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.

Parameters
numberOfTrials:int

number of trials

numberOfSuccesses:int

number of successes

confidenceLevel:double

desired probability that the true probability of success falls within the interval

Returns:ConfidenceInterval

Confidence interval containing the probability of success with probability confidenceLevel

getWilsonScoreIntervalback to summary
public 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.

Parameters
numberOfTrials:int

number of trials

numberOfSuccesses:int

number of successes

confidenceLevel:double

desired probability that the true probability of success falls within the returned interval

Returns:ConfidenceInterval

Confidence interval containing the probability of success with probability confidenceLevel

Exceptions
NotStrictlyPositiveException:
if numberOfTrials <= 0.
NotPositiveException:
if numberOfSuccesses < 0.
NumberIsTooLargeException:
if numberOfSuccesses > numberOfTrials.
OutOfRangeException:
if confidenceLevel is not in the interval (0, 1).