Enum BinomialConfidenceInterval

java.lang.Object
java.lang.Enum<BinomialConfidenceInterval>
org.apache.commons.statistics.interval.BinomialConfidenceInterval
All Implemented Interfaces:
Serializable, Comparable<BinomialConfidenceInterval>

public enum BinomialConfidenceInterval extends 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 the normal approximation and Agresti-Coull methods.

Since:
1.2
See Also:
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    Implements the Agresti-Coull method for creating a binomial proportion confidence interval.
    Implements the Clopper-Pearson method for creating a binomial proportion confidence interval.
    Implements the Jeffreys method for creating a binomial proportion confidence interval.
    Implements the normal approximation method for creating a binomial proportion confidence interval.
    Implements the Wilson score method for creating a binomial proportion confidence interval.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) static final NormalDistribution
    The standard normal distribution.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) static double
    clip(double p)
    Clip the probability to [0, 1].
    (package private) 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.
    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.
    Returns the enum constant of this type with the specified name.
    Returns an array containing the constants of this enum type, in the order they are declared.

    Methods inherited from class Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

  • Field Details

    • NORMAL_DISTRIBUTION

      static final NormalDistribution NORMAL_DISTRIBUTION
      The standard normal distribution.
  • Constructor Details

    • BinomialConfidenceInterval

      private BinomialConfidenceInterval()
  • Method Details

    • values

      public static BinomialConfidenceInterval[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static BinomialConfidenceInterval valueOf(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:
      IllegalArgumentException - if this enum type has no constant with the specified name
      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 alpha is related to the confidence level that the interval contains the true probability of success as alpha = 1 - confidence, where confidence is the confidence level in [0, 1]. For example a 95% confidence level is an alpha of 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:
      IllegalArgumentException - if numberOfTrials <= 0, if numberOfSuccesses < 0, if numberOfSuccesses > numberOfTrials, or if alpha is 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]