public class PoissonDistribution extends AbstractIntegerDistribution
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.
|
random, randomData
Constructor and Description |
---|
PoissonDistribution(double p)
Creates a new Poisson distribution with specified mean.
|
PoissonDistribution(double p,
double epsilon)
Creates a new Poisson distribution with the specified mean and
convergence criterion.
|
PoissonDistribution(double p,
double epsilon,
int maxIterations)
Creates a new Poisson distribution with specified mean, convergence
criterion and maximum number of iterations.
|
PoissonDistribution(double p,
int maxIterations)
Creates a new Poisson distribution with the specified mean and maximum
number of iterations.
|
PoissonDistribution(RandomGenerator rng,
double p,
double epsilon,
int maxIterations)
Creates a new Poisson distribution with specified mean, convergence
criterion and maximum number of iterations.
|
Modifier and Type | Method and Description |
---|---|
double |
cumulativeProbability(int x)
For a random variable
X whose values are distributed according
to this distribution, this method returns P(X <= x) . |
double |
getMean()
Get the mean for the distribution.
|
double |
getNumericalMean()
Use this method to get the numerical value of the mean of this
distribution.
|
double |
getNumericalVariance()
Use this method to get the numerical value of the variance of this
distribution.
|
int |
getSupportLowerBound()
Access the lower bound of the support.
|
int |
getSupportUpperBound()
Access the upper bound of the support.
|
boolean |
isSupportConnected()
Use this method to get information about whether the support is
connected, i.e.
|
double |
logProbability(int x)
For a random variable
X whose values are distributed according to
this distribution, this method returns log(P(X = x)) , where
log is the natural logarithm. |
double |
normalApproximateProbability(int x)
Calculates the Poisson distribution function using a normal
approximation.
|
double |
probability(int x)
For a random variable
X whose values are distributed according
to this distribution, this method returns P(X = x) . |
int |
sample()
Generate a random value sampled from this distribution.
|
cumulativeProbability, inverseCumulativeProbability, reseedRandomGenerator, sample, solveInverseCumulativeProbability
public static final int DEFAULT_MAX_ITERATIONS
public static final double DEFAULT_EPSILON
public PoissonDistribution(double p) throws NotStrictlyPositiveException
Note: this constructor will implicitly create an instance of
Well19937c
as random generator to be used for sampling only (see
sample()
and AbstractIntegerDistribution.sample(int)
). In case no sampling is
needed for the created distribution, it is advised to pass null
as random generator via the appropriate constructors to avoid the
additional initialisation overhead.
p
- the Poisson meanNotStrictlyPositiveException
- if p <= 0
.public PoissonDistribution(double p, double epsilon, int maxIterations) throws NotStrictlyPositiveException
Note: this constructor will implicitly create an instance of
Well19937c
as random generator to be used for sampling only (see
sample()
and AbstractIntegerDistribution.sample(int)
). In case no sampling is
needed for the created distribution, it is advised to pass null
as random generator via the appropriate constructors to avoid the
additional initialisation overhead.
p
- Poisson mean.epsilon
- Convergence criterion for cumulative probabilities.maxIterations
- the maximum number of iterations for cumulative
probabilities.NotStrictlyPositiveException
- if p <= 0
.public PoissonDistribution(RandomGenerator rng, double p, double epsilon, int maxIterations) throws NotStrictlyPositiveException
rng
- Random number generator.p
- Poisson mean.epsilon
- Convergence criterion for cumulative probabilities.maxIterations
- the maximum number of iterations for cumulative
probabilities.NotStrictlyPositiveException
- if p <= 0
.public PoissonDistribution(double p, double epsilon) throws NotStrictlyPositiveException
p
- Poisson mean.epsilon
- Convergence criterion for cumulative probabilities.NotStrictlyPositiveException
- if p <= 0
.public PoissonDistribution(double p, int maxIterations)
p
- Poisson mean.maxIterations
- Maximum number of iterations for cumulative
probabilities.public double getMean()
public double probability(int x)
X
whose values are distributed according
to this distribution, this method returns P(X = x)
. In other
words, this method represents the probability mass function (PMF)
for the distribution.x
- the point at which the PMF is evaluatedx
public double logProbability(int x)
X
whose values are distributed according to
this distribution, this method returns log(P(X = x))
, where
log
is the natural logarithm. In other words, this method
represents the logarithm of the probability mass function (PMF) for the
distribution. Note that due to the floating point precision and
under/overflow issues, this method will for some distributions be more
precise and faster than computing the logarithm of
IntegerDistribution.probability(int)
.
The default implementation simply computes the logarithm of probability(x)
.
logProbability
in class AbstractIntegerDistribution
x
- the point at which the PMF is evaluatedx
public double cumulativeProbability(int x)
X
whose values are distributed according
to this distribution, this method returns P(X <= x)
. In other
words, this method represents the (cumulative) distribution function
(CDF) for this distribution.x
- the point at which the CDF is evaluatedx
public double normalApproximateProbability(int x)
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
).x
- Upper bound, inclusive.public double getNumericalMean()
p
, the mean is p
.Double.NaN
if it is not definedpublic double getNumericalVariance()
p
, the variance is p
.Double.POSITIVE_INFINITY
or
Double.NaN
if it is not defined)public int getSupportLowerBound()
inverseCumulativeProbability(0)
. In other words, this
method must return
inf {x in Z | P(X <= x) > 0}
.
public int getSupportUpperBound()
inverseCumulativeProbability(1)
. In other words, this
method must return
inf {x in R | P(X <= x) = 1}
.
Integer.MAX_VALUE
.Integer.MAX_VALUE
for
positive infinity)public boolean isSupportConnected()
true
public int sample()
Algorithm Description:
Devroye, Luc. (1981).The Computer Generation of Poisson Random Variables
Computing vol. 26 pp. 197-207.
sample
in interface IntegerDistribution
sample
in class AbstractIntegerDistribution
Copyright © 2003–2016 The Apache Software Foundation. All rights reserved.