|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.math3.distribution.AbstractIntegerDistribution
public abstract class AbstractIntegerDistribution
Base class for integer-valued discrete distributions. Default implementations are provided for some of the methods that do not vary from distribution to distribution.
Field Summary | |
---|---|
protected RandomGenerator |
random
RNG instance used to generate samples from the distribution. |
protected RandomDataImpl |
randomData
Deprecated. As of 3.1, to be removed in 4.0. Please use the random instance variable instead. |
Constructor Summary | |
---|---|
protected |
AbstractIntegerDistribution()
Deprecated. As of 3.1, to be removed in 4.0. Please use AbstractIntegerDistribution(RandomGenerator) instead. |
protected |
AbstractIntegerDistribution(RandomGenerator rng)
|
Method Summary | |
---|---|
double |
cumulativeProbability(int x0,
int x1)
For a random variable X whose values are distributed according
to this distribution, this method returns P(x0 < X <= x1) . |
int |
inverseCumulativeProbability(double p)
Computes the quantile function of this distribution. |
void |
reseedRandomGenerator(long seed)
Reseed the random generator used to generate samples. |
int |
sample()
Generate a random value sampled from this distribution. |
int[] |
sample(int sampleSize)
Generate a random sample from the distribution. |
protected int |
solveInverseCumulativeProbability(double p,
int lower,
int upper)
This is a utility function used by inverseCumulativeProbability(double) . |
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.math3.distribution.IntegerDistribution |
---|
cumulativeProbability, getNumericalMean, getNumericalVariance, getSupportLowerBound, getSupportUpperBound, isSupportConnected, probability |
Field Detail |
---|
@Deprecated protected final RandomDataImpl randomData
random
instance variable instead.
protected final RandomGenerator random
Constructor Detail |
---|
@Deprecated protected AbstractIntegerDistribution()
AbstractIntegerDistribution(RandomGenerator)
instead.
protected AbstractIntegerDistribution(RandomGenerator rng)
rng
- Random number generator.Method Detail |
---|
public double cumulativeProbability(int x0, int x1) throws NumberIsTooLargeException
X
whose values are distributed according
to this distribution, this method returns P(x0 < X <= x1)
.
The default implementation uses the identity
P(x0 < X <= x1) = P(X <= x1) - P(X <= x0)
cumulativeProbability
in interface IntegerDistribution
x0
- the exclusive lower boundx1
- the inclusive upper bound
x0
and x1
,
excluding the lower and including the upper endpoint
NumberIsTooLargeException
- if x0 > x1
public int inverseCumulativeProbability(double p) throws OutOfRangeException
X
distributed according to this distribution,
the returned value is
inf{x in Z | P(X<=x) >= p}
for 0 < p <= 1
,inf{x in Z | P(X<=x) > 0}
for p = 0
.int
,
then Integer.MIN_VALUE
or Integer.MAX_VALUE
is returned.
The default implementation returns
IntegerDistribution.getSupportLowerBound()
for p = 0
,IntegerDistribution.getSupportUpperBound()
for p = 1
, andsolveInverseCumulativeProbability(double, int, int)
for
0 < p < 1
.
inverseCumulativeProbability
in interface IntegerDistribution
p
- the cumulative probability
p
-quantile of this distribution
(largest 0-quantile for p = 0
)
OutOfRangeException
- if p < 0
or p > 1
protected int solveInverseCumulativeProbability(double p, int lower, int upper)
inverseCumulativeProbability(double)
. It assumes 0 < p < 1
and
that the inverse cumulative probability lies in the bracket (lower, upper]
. The implementation does simple bisection to find the
smallest p
-quantile inf{x in Z | P(X<=x) >= p}
.
p
- the cumulative probabilitylower
- a value satisfying cumulativeProbability(lower) < p
upper
- a value satisfying p <= cumulativeProbability(upper)
p
-quantile of this distributionpublic void reseedRandomGenerator(long seed)
reseedRandomGenerator
in interface IntegerDistribution
seed
- the new seedpublic int sample()
sample
in interface IntegerDistribution
public int[] sample(int sampleSize)
sample()
in a loop.
sample
in interface IntegerDistribution
sampleSize
- the number of random values to generate
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |