Class BinomialDistributionImpl

    • Constructor Detail

      • BinomialDistributionImpl

        public BinomialDistributionImpl​(int trials,
                                        double p)
        Create a binomial distribution with the given number of trials and probability of success.
        Parameters:
        trials - the number of trials.
        p - the probability of success.
    • Method Detail

      • getNumberOfTrials

        public int getNumberOfTrials()
        Access the number of trials for this distribution.
        Specified by:
        getNumberOfTrials in interface BinomialDistribution
        Returns:
        the number of trials.
      • getProbabilityOfSuccess

        public double getProbabilityOfSuccess()
        Access the probability of success for this distribution.
        Specified by:
        getProbabilityOfSuccess in interface BinomialDistribution
        Returns:
        the probability of success.
      • setNumberOfTrials

        @Deprecated
        public void setNumberOfTrials​(int trials)
        Deprecated.
        as of 2.1 (class will become immutable in 3.0)
        Change the number of trials for this distribution.
        Specified by:
        setNumberOfTrials in interface BinomialDistribution
        Parameters:
        trials - the new number of trials.
        Throws:
        java.lang.IllegalArgumentException - if trials is not a valid number of trials.
      • setProbabilityOfSuccess

        @Deprecated
        public void setProbabilityOfSuccess​(double p)
        Deprecated.
        as of 2.1 (class will become immutable in 3.0)
        Change the probability of success for this distribution.
        Specified by:
        setProbabilityOfSuccess in interface BinomialDistribution
        Parameters:
        p - the new probability of success.
        Throws:
        java.lang.IllegalArgumentException - if p is not a valid probability.
      • probability

        public double probability​(int x)
        For this distribution, X, this method returns P(X = x).
        Specified by:
        probability in interface IntegerDistribution
        Parameters:
        x - the value at which the PMF is evaluated.
        Returns:
        PMF for this distribution.
      • inverseCumulativeProbability

        public int inverseCumulativeProbability​(double p)
                                         throws MathException
        For this distribution, X, this method returns the largest x, such that P(X ≤ x) ≤ p.

        Returns -1 for p=0 and Integer.MAX_VALUE for p=1.

        Specified by:
        inverseCumulativeProbability in interface IntegerDistribution
        Overrides:
        inverseCumulativeProbability in class AbstractIntegerDistribution
        Parameters:
        p - the desired probability
        Returns:
        the largest x such that P(X ≤ x) <= p
        Throws:
        MathException - if the inverse cumulative probability can not be computed due to convergence or other numerical errors.
        java.lang.IllegalArgumentException - if p < 0 or p > 1
      • getSupportLowerBound

        public int getSupportLowerBound()
        Returns the lower bound of the support for the distribution. The lower bound of the support is always 0 no matter the number of trials and probability parameter.
        Returns:
        lower bound of the support (always 0)
        Since:
        2.2
      • getSupportUpperBound

        public int getSupportUpperBound()
        Returns the upper bound of the support for the distribution. The upper bound of the support is the number of trials.
        Returns:
        upper bound of the support (equal to number of trials)
        Since:
        2.2
      • getNumericalMean

        public double getNumericalMean()
        Returns the mean. For n number of trials and probability parameter p, the mean is n * p
        Returns:
        the mean
        Since:
        2.2
      • getNumericalVariance

        public double getNumericalVariance()
        Returns the variance. For n number of trials and probability parameter p, the variance is n * p * (1 - p)
        Returns:
        the variance
        Since:
        2.2