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

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

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

    public class PoissonDistributionImpl

extends AbstractIntegerDistribution
implements PoissonDistribution, java.io.Serializable

Implementation for the `PoissonDistribution`.

Version:
  $Revision: 772119 $ $Date: 2009-05-06 05:43:28 -0400 (Wed, 06 May 2009) $
See Also:
  Serialized Form

Field Summary
`private double` `mean` Holds the Poisson mean for the distribution.
`private NormalDistribution` `normal` Distribution used to compute normal approximation.
`private static long` `serialVersionUID` Serializable version identifier

Constructor Summary
`PoissonDistributionImpl(double p)` Create a new Poisson distribution with the given the mean.
`PoissonDistributionImpl(double p, NormalDistribution z)` Create a new Poisson distribution with the given the mean.

Method Summary
`double` `cumulativeProbability(int x)` The probability distribution function P(X <= x) for a Poisson distribution.
`protected int` `getDomainLowerBound(double p)` Access the domain value lower bound, based on `p`, used to bracket a CDF root.
`protected int` `getDomainUpperBound(double p)` Access the domain value upper bound, based on `p`, used to bracket a CDF root.
`double` `getMean()` Get the Poisson mean for the distribution.
`double` `normalApproximateProbability(int x)` Calculates the Poisson distribution function using a normal approximation.
`double` `probability(int x)` The probability mass function P(X = x) for a Poisson distribution.
`void` `setMean(double p)` Set the Poisson mean for the distribution.
`void` `setNormal(NormalDistribution value)` Modify the normal distribution used to compute normal approximations.

Methods inherited from class org.apache.commons.math.distribution.AbstractIntegerDistribution
`cumulativeProbability, cumulativeProbability, cumulativeProbability, inverseCumulativeProbability, 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, inverseCumulativeProbability`

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

### normal

    private NormalDistribution normal

  Distribution used to compute normal approximation.

### mean

    private double mean

  Holds the Poisson mean for the distribution.

Constructor Detail

### PoissonDistributionImpl

    public PoissonDistributionImpl(double p)

  Create a new Poisson distribution with the given the mean. The mean value must be positive; otherwise an `IllegalArgument` is thrown.

  Parameters:
    `p` - the Poisson mean
  Throws:
    `java.lang.IllegalArgumentException` - if p ≤ 0

### PoissonDistributionImpl

    public PoissonDistributionImpl(double p,
                                   NormalDistribution z)

  Create a new Poisson distribution with the given the mean. The mean value must be positive; otherwise an `IllegalArgument` is thrown.

  Parameters:
    `p` - the Poisson mean
    `z` - a normal distribution used to compute normal approximations.
  Throws:
    `java.lang.IllegalArgumentException` - if p ≤ 0
  Since:
    1.2

Method Detail

### getMean

    public double getMean()

  Get the Poisson mean for the distribution.

  Specified by:
    `getMean` in interface `PoissonDistribution`
  Returns:
    the Poisson mean for the distribution.

### setMean

    public void setMean(double p)

  Set the Poisson mean for the distribution. The mean value must be positive; otherwise an `IllegalArgument` is thrown.

  Specified by:
    `setMean` in interface `PoissonDistribution`
  Parameters:
    `p` - the Poisson mean value
  Throws:
    `java.lang.IllegalArgumentException` - if p ≤ 0

### probability

    public double probability(int x)

  The probability mass function P(X = x) for a Poisson distribution.

  Specified by:
    `probability` in interface `IntegerDistribution`
  Parameters:
    `x` - the value at which the probability density function is evaluated.
  Returns:
    the value of the probability mass function at x

### cumulativeProbability

    public double cumulativeProbability(int x)
                                 throws MathException

  The probability distribution function P(X <= x) for a Poisson distribution.

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

### normalApproximateProbability

    public double normalApproximateProbability(int x)
                                        throws MathException

  Calculates the Poisson distribution function using a normal approximation. The `N(mean, sqrt(mean))` distribution is used to approximate the Poisson distribution.

  The computation uses "half-correction" -- evaluating the normal distribution function at `x + 0.5`

  Specified by:
    `normalApproximateProbability` in interface `PoissonDistribution`
  Parameters:
    `x` - the upper bound, inclusive
  Returns:
    the distribution function value calculated using a normal approximation
  Throws:
    `MathException` - if an error occurs computing the normal approximation

### getDomainLowerBound

    protected int getDomainLowerBound(double p)

  Access the domain value lower bound, based on `p`, used to bracket a CDF root. This method is used by `AbstractIntegerDistribution.inverseCumulativeProbability(double)` to find critical values.

  Specified by:
    `getDomainLowerBound` in class `AbstractIntegerDistribution`
  Parameters:
    `p` - the desired probability for the critical value
  Returns:
    domain lower bound

### getDomainUpperBound

    protected int getDomainUpperBound(double p)

  Access the domain value upper bound, based on `p`, used to bracket a CDF root. This method is used by `AbstractIntegerDistribution.inverseCumulativeProbability(double)` to find critical values.

  Specified by:
    `getDomainUpperBound` in class `AbstractIntegerDistribution`
  Parameters:
    `p` - the desired probability for the critical value
  Returns:
    domain upper bound

### setNormal

    public void setNormal(NormalDistribution value)

  Modify the normal distribution used to compute normal approximations. The caller is responsible for insuring the normal distribution has the proper parameter settings.

  Parameters:
    `value` - the new distribution
  Since:
    1.2

Copyright (c) 2003-2010 Apache Software Foundation