org.apache.commons.math.distribution
public class PoissonDistributionImpl extends AbstractIntegerDistribution implements PoissonDistribution, Serializable
PoissonDistribution
.Modifier and Type | Field and Description |
---|---|
static double |
DEFAULT_EPSILON
Default convergence criterion.
|
static int |
DEFAULT_MAX_ITERATIONS
Default maximum number of iterations for cumulative probability calculations.
|
private double |
epsilon
Convergence criterion for cumulative probability.
|
private int |
maxIterations
Maximum number of iterations for cumulative probability.
|
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
|
randomData
Constructor and Description |
---|
PoissonDistributionImpl(double p)
Create a new Poisson distribution with the given the mean.
|
PoissonDistributionImpl(double p,
double epsilon)
Create a new Poisson distribution with the given mean and convergence criterion.
|
PoissonDistributionImpl(double p,
double epsilon,
int maxIterations)
Create a new Poisson distribution with the given mean, convergence criterion
and maximum number of iterations.
|
PoissonDistributionImpl(double p,
int maxIterations)
Create a new Poisson distribution with the given mean and maximum number of iterations.
|
PoissonDistributionImpl(double p,
NormalDistribution z)
Deprecated.
as of 2.1 (to avoid possibly inconsistent state, the
"NormalDistribution" will be instantiated internally)
|
Modifier and Type | Method and Description |
---|---|
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 |
getNumericalVariance()
Returns the variance of the distribution.
|
int |
getSupportLowerBound()
Returns the lower bound of the support for the distribution.
|
int |
getSupportUpperBound()
Returns the upper bound of the support 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.
|
int |
sample()
Generates a random value sampled from this distribution.
|
void |
setMean(double p)
Deprecated.
as of 2.1 (class will become immutable in 3.0)
|
void |
setNormal(NormalDistribution value)
Deprecated.
as of 2.1 (class will become immutable in 3.0)
|
private void |
setNormalAndMeanInternal(NormalDistribution z,
double p)
Set the Poisson mean for the distribution.
|
cumulativeProbability, cumulativeProbability, cumulativeProbability, inverseCumulativeProbability, isSupportLowerBoundInclusive, isSupportUpperBoundInclusive, probability, reseedRandomGenerator, sample
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
cumulativeProbability, inverseCumulativeProbability
probability
cumulativeProbability, cumulativeProbability
public static final int DEFAULT_MAX_ITERATIONS
public static final double DEFAULT_EPSILON
private static final long serialVersionUID
private NormalDistribution normal
private double mean
private int maxIterations
private double epsilon
public PoissonDistributionImpl(double p)
IllegalArgument
is thrown.p
- the Poisson meanIllegalArgumentException
- if p ≤ 0public PoissonDistributionImpl(double p, double epsilon, int maxIterations)
p
- the Poisson meanepsilon
- the convergence criteria for cumulative probabilitesmaxIterations
- the maximum number of iterations for cumulative probabilitespublic PoissonDistributionImpl(double p, double epsilon)
p
- the Poisson meanepsilon
- the convergence criteria for cumulative probabilitespublic PoissonDistributionImpl(double p, int maxIterations)
p
- the Poisson meanmaxIterations
- the maximum number of iterations for cumulative probabilites@Deprecated public PoissonDistributionImpl(double p, NormalDistribution z)
IllegalArgument
is thrown.p
- the Poisson meanz
- a normal distribution used to compute normal approximations.IllegalArgumentException
- if p ≤ 0public double getMean()
getMean
in interface PoissonDistribution
@Deprecated public void setMean(double p)
IllegalArgument
is thrown.setMean
in interface PoissonDistribution
p
- the Poisson mean valueIllegalArgumentException
- if p ≤ 0private void setNormalAndMeanInternal(NormalDistribution z, double p)
IllegalArgument
is thrown.z
- the new distributionp
- the Poisson mean valueIllegalArgumentException
- if p ≤ 0public double probability(int x)
probability
in interface IntegerDistribution
x
- the value at which the probability density function is
evaluated.public double cumulativeProbability(int x) throws MathException
cumulativeProbability
in interface IntegerDistribution
cumulativeProbability
in class AbstractIntegerDistribution
x
- the value at which the PDF is evaluated.MathException
- if the cumulative probability can not be computed
due to convergence or other numerical errors.public double normalApproximateProbability(int x) throws MathException
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
normalApproximateProbability
in interface PoissonDistribution
x
- the upper bound, inclusiveMathException
- if an error occurs computing the normal
approximationpublic int sample() throws MathException
Algorithm Description:
sample
in class AbstractIntegerDistribution
MathException
- if an error occurs generating the random valueprotected int getDomainLowerBound(double p)
p
, used to
bracket a CDF root. This method is used by
AbstractIntegerDistribution.inverseCumulativeProbability(double)
to find critical values.getDomainLowerBound
in class AbstractIntegerDistribution
p
- the desired probability for the critical valueprotected int getDomainUpperBound(double p)
p
, used to
bracket a CDF root. This method is used by
AbstractIntegerDistribution.inverseCumulativeProbability(double)
to find critical values.getDomainUpperBound
in class AbstractIntegerDistribution
p
- the desired probability for the critical value@Deprecated public void setNormal(NormalDistribution value)
value
- the new distributionpublic int getSupportLowerBound()
public int getSupportUpperBound()
Integer.MAX_VALUE
and
AbstractIntegerDistribution.isSupportUpperBoundInclusive()
returns true
.Integer.MAX_VALUE
for positive infinity)public double getNumericalVariance()
p
, the variance is p
Copyright (c) 2003-2014 Apache Software Foundation