Package org.evoludo.math
Class RNGDistribution.Exponential
Object
RNGDistribution
Exponential
- Enclosing class:
RNGDistribution
Exponentially distributed random numbers with support
[0.0, Double.MAX_VALUE).- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class RNGDistribution
RNGDistribution.Binomial, RNGDistribution.Exponential, RNGDistribution.Geometric, RNGDistribution.Gillespie, RNGDistribution.Normal, RNGDistribution.TestCommand, RNGDistribution.Uniform -
Field Summary
FieldsFields inherited from class RNGDistribution
rng, seed, seedSet, testSamples -
Constructor Summary
ConstructorsConstructorDescriptionCreates exponential distribution withmean==1and a new instance ofMersenneTwister.Exponential(double mean) Creates exponential distribution withmeanand a new instance ofMersenneTwister.Exponential(MersenneTwister rng, double mean) Creates exponential distribution withmeanand random number generatorrng. -
Method Summary
Modifier and TypeMethodDescriptionprivate static doublecdf(double x, double mean) Helper method to calculate the cumulative distribution function,cdf, of the Exponential distribution.clone()Clone this RNGDistribution to ensure both objects return identical sequences of random numbers.doublegetMean()Get the mean of the exponential distribution.doublenext()Generate an exponentially distributed random number withmean.static doublenext(MersenneTwister rng, double mean) Exponentially distributed random number withmeanusing random number generatorrng.static voidtest(MersenneTwister rng, Logger logger, MersenneTwister.Chronometer clock) Test Exponential distribution.Methods inherited from class RNGDistribution
clearRNGSeed, clone, getRNG, getRNGSeed, isRNGSeedSet, nextBoolean, nextByte, nextBytes, nextDouble, nextGaussian, nextInt, nextInt, random01, random01d, random0n, random0N, setRNG, setRNGSeed, setRNGSeed
-
Field Details
-
mean
private double meanThe mean of exponential distribution.
-
-
Constructor Details
-
Exponential
public Exponential()Creates exponential distribution withmean==1and a new instance ofMersenneTwister. -
Exponential
public Exponential(double mean) Creates exponential distribution withmeanand a new instance ofMersenneTwister.- Parameters:
mean- the mean of the exponential distribution
-
Exponential
Creates exponential distribution withmeanand random number generatorrng.- Parameters:
rng- the random number generatormean- the mean of the exponential distribution- Throws:
IllegalArgumentException- ifmean≤0- See Also:
-
-
Method Details
-
getMean
public double getMean()Get the mean of the exponential distribution.- Returns:
- the mean
-
next
public double next()Generate an exponentially distributed random number withmean.- Returns:
- the exponentially distributed random number
-
clone
Description copied from class:RNGDistributionClone this RNGDistribution to ensure both objects return identical sequences of random numbers.IMPORTANT:
- Specified by:
clonein classRNGDistribution- Returns:
- clone of RNGDistribution
-
next
Exponentially distributed random number withmeanusing random number generatorrng.Note: no performance difference between the instance method
next()and this static counterpart.- Parameters:
rng- random number generatormean- of exponential distribution- Returns:
- exponentially distributed random number with
mean - Throws:
IllegalArgumentException- ifman≤0
-
test
Test Exponential distribution.The test samples the distribution and bins the random numbers. This sample distribution is compared to the theoretical expectation. The mean deviation is the mean difference between the actual number of events in each bin and their expected number. For a perfect match the mean deviation is
0. The test passes if the mean deviation lies within one standard error from0. This is more stringent than the traditional 95% confidence interval.- Parameters:
rng- the random number generatorlogger- the logger for reporting resultsclock- the stop watch- See Also:
-
cdf
private static double cdf(double x, double mean) Helper method to calculate the cumulative distribution function,cdf, of the Exponential distribution.- Parameters:
x- the value for which to calculate thecdfmean- the mean value- Returns:
cdfatx
-