BinomialConfidenceInterval
org.apache.commons.math3.stat.inference

Class BinomialConfidenceInterval



  • public class BinomialConfidenceIntervalextends Object
    Factory methods to generate confidence intervals for a binomial proportion. The supported methods are:
    • Clopper-Pearson method (exact method)
    • Normal approximation (based on central limit theorem)
    • Agresti-Coull interval
    • Wilson score interval
    See Also:
    Binomial proportion confidence interval (Wikipedia)
    • Method Summary

      Methods 
      Modifier and TypeMethod and Description
      ConfidenceIntervalgetAgrestiCoullInterval(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.
      ConfidenceIntervalgetClopperPearsonInterval(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.
      ConfidenceIntervalgetNormalApproximationInterval(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.
      ConfidenceIntervalgetWilsonScoreInterval(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.
    • Constructor Detail

      • BinomialConfidenceInterval

        public BinomialConfidenceInterval()
    • Method Detail

      • getClopperPearsonInterval

        public 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 - number of trials
        numberOfSuccesses - number of successes
        confidenceLevel - 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:
        NotStrictlyPositiveException - if numberOfTrials <= 0.
        NotPositiveException - if numberOfSuccesses < 0.
        NumberIsTooLargeException - if numberOfSuccesses > numberOfTrials.
        OutOfRangeException - if confidenceLevel is not in the interval (0, 1).
      • getNormalApproximationInterval

        public 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 - number of trials
        numberOfSuccesses - number of successes
        confidenceLevel - desired probability that the true probability of success falls within the interval
        Returns:
        Confidence interval containing the probability of success with probability confidenceLevel
      • getAgrestiCoullInterval

        public 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 - number of trials
        numberOfSuccesses - number of successes
        confidenceLevel - 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:
        NotStrictlyPositiveException - if numberOfTrials <= 0.
        NotPositiveException - if numberOfSuccesses < 0.
        NumberIsTooLargeException - if numberOfSuccesses > numberOfTrials.
        OutOfRangeException - if confidenceLevel is not in the interval (0, 1).
      • getWilsonScoreInterval

        public 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 - number of trials
        numberOfSuccesses - number of successes
        confidenceLevel - 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:
        NotStrictlyPositiveException - if numberOfTrials <= 0.
        NotPositiveException - if numberOfSuccesses < 0.
        NumberIsTooLargeException - if numberOfSuccesses > numberOfTrials.
        OutOfRangeException - if confidenceLevel is not in the interval (0, 1).

SCaVis 2.1 © jWork.ORG