Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.commons.math.distribution
Class BinomialDistributionImpl

    java.lang.Object
      org.apache.commons.math.distribution.AbstractDistribution
          org.apache.commons.math.distribution.AbstractIntegerDistribution
              org.apache.commons.math.distribution.BinomialDistributionImpl

All Implemented Interfaces:
  java.io.Serializable, BinomialDistribution, DiscreteDistribution, Distribution, IntegerDistribution

    public class BinomialDistributionImpl

extends AbstractIntegerDistribution
implements BinomialDistribution, java.io.Serializable

The default implementation of `BinomialDistribution`.

Version:
  $Revision: 920852 $ $Date: 2010-03-09 07:53:44 -0500 (Tue, 09 Mar 2010) $
See Also:
  Serialized Form

Field Summary
`private int` | `numberOfTrials` The number of trials.
`private double` | `probabilityOfSuccess` The probability of success.
`private static long` | `serialVersionUID` Serializable version identifier

Constructor Summary
`BinomialDistributionImpl(int trials, double p)` Create a binomial distribution with the given number of trials and probability of success.

Method Summary
`double` | `cumulativeProbability(int x)` For this distribution, X, this method returns P(X ≤ x).
`protected int` | `getDomainLowerBound(double p)` Access the domain value lower bound, based on `p`, used to bracket a PDF root.
`protected int` | `getDomainUpperBound(double p)` Access the domain value upper bound, based on `p`, used to bracket a PDF root.
`int` | `getNumberOfTrials()` Access the number of trials for this distribution.
`double` | `getProbabilityOfSuccess()` Access the probability of success for this distribution.
`int` | `inverseCumulativeProbability(double p)` For this distribution, X, this method returns the largest x, such that P(X ≤ x) ≤ `p`.
`double` | `probability(int x)` For this distribution, X, this method returns P(X = x).
`void` | `setNumberOfTrials(int trials)` Deprecated. as of 2.1 (class will become immutable in 3.0)
`private void` | `setNumberOfTrialsInternal(int trials)` Change the number of trials for this distribution.
`void` | `setProbabilityOfSuccess(double p)` Deprecated. as of 2.1 (class will become immutable in 3.0)
`private void` | `setProbabilityOfSuccessInternal(double p)` Change the probability of success for this distribution.

Methods inherited from class org.apache.commons.math.distribution.AbstractIntegerDistribution
`cumulativeProbability, cumulativeProbability, cumulativeProbability, probability`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface org.apache.commons.math.distribution.IntegerDistribution
`cumulativeProbability`

Methods inherited from interface org.apache.commons.math.distribution.DiscreteDistribution
`probability`

Methods inherited from interface org.apache.commons.math.distribution.Distribution
`cumulativeProbability, cumulativeProbability`

Field Detail

### serialVersionUID

    private static final long serialVersionUID

  Serializable version identifier

  See Also:
    Constant Field Values

### numberOfTrials

    private int numberOfTrials

  The number of trials.

### probabilityOfSuccess

    private double probabilityOfSuccess

  The probability of success.

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.

### setNumberOfTrialsInternal

    private void setNumberOfTrialsInternal(int trials)

  Change the number of trials for this distribution.

  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.

### setProbabilityOfSuccessInternal

    private void setProbabilityOfSuccessInternal(double p)

  Change the probability of success for this distribution.

  Parameters:
    `p` - the new probability of success.
  Throws:
    `java.lang.IllegalArgumentException` - if `p` is not a valid probability.

### getDomainLowerBound

    protected int getDomainLowerBound(double p)

  Access the domain value lower bound, based on `p`, used to bracket a PDF root.

  Specified by:
    `getDomainLowerBound` in class `AbstractIntegerDistribution`
  Parameters:
    `p` - the desired probability for the critical value
  Returns:
    domain value lower bound, i.e. P(X < lower bound) < `p`

### getDomainUpperBound

    protected int getDomainUpperBound(double p)

  Access the domain value upper bound, based on `p`, used to bracket a PDF root.

  Specified by:
    `getDomainUpperBound` in class `AbstractIntegerDistribution`
  Parameters:
    `p` - the desired probability for the critical value
  Returns:
    domain value upper bound, i.e. P(X < upper bound) > `p`

### cumulativeProbability

    public double cumulativeProbability(int x)
                                 throws MathException

  For this distribution, X, this method returns P(X ≤ x).

  Specified by:
    `cumulativeProbability` in interface `IntegerDistribution`
  Specified by:
    `cumulativeProbability` in class `AbstractIntegerDistribution`
  Parameters:
    `x` - the value at which the PDF is evaluated.
  Returns:
    PDF for this distribution.
  Throws:
    `MathException` - if the cumulative probability can not be computed due to convergence or other numerical errors.

### 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

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (c) 2003-2011 Apache Software Foundation