Package org.evoludo.math
Class RNGDistribution.Uniform
Object
RNGDistribution
Uniform
- Enclosing class:
RNGDistribution
Uniformly distributed random numbers with support
[min, max)
.- 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
FieldsModifier and TypeFieldDescriptionprivate double
Lower bound of uniform interval (inclusive).private double
Width of interval of uniform random numbers,max-min
.Fields inherited from class RNGDistribution
rng, seed, seedSet, testSamples
-
Constructor Summary
ConstructorsConstructorDescriptionUniform()
Creates uniform random distribution in interval[0,1)
with new instance ofMersenneTwister
.Uniform
(double min, double max) Creates uniform random distribution in interval[min, max)
with new instance ofMersenneTwister
.Uniform
(MersenneTwister rng, double min, double max) Creates uniform random distribution in interval[min, max)
with random number generatorrng
. -
Method Summary
Modifier and TypeMethodDescriptionprivate static double
cdf
(double x, double min, double max) Helper method to calculate the cumulative distribution function,cdf
, of the Uniform distribution.clone()
Clone this RNGDistribution to ensure both objects return identical sequences of random numbers.double
getMax()
Get the upper bound of the uniform distribution (exclusive).double
getMin()
Get the lower bound of the uniform distribution (inclusive).double
getRange()
Get the range of the uniform distribution.double
next()
Generate a uniformly distributed random number from interval[min, max)
.static double
next
(MersenneTwister rng, double min, double max) Uniformly distributed random number in[min, max)
using random number generatorrng
.static void
test
(MersenneTwister rng, Logger logger, MersenneTwister.Chronometer clock) Test Uniform 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
-
min
private double minLower bound of uniform interval (inclusive). -
range
private double rangeWidth of interval of uniform random numbers,max-min
.
-
-
Constructor Details
-
Uniform
public Uniform()Creates uniform random distribution in interval[0,1)
with new instance ofMersenneTwister
. -
Uniform
public Uniform(double min, double max) Creates uniform random distribution in interval[min, max)
with new instance ofMersenneTwister
.- Parameters:
min
- lower bound of uniform interval (inclusive)max
- upper bound of uniform interval (exclusive)
-
Uniform
Creates uniform random distribution in interval[min, max)
with random number generatorrng
.- Parameters:
rng
- random number generatormin
- lower bound of uniform interval (inclusive)max
- upper bound of uniform interval (exclusive)- Throws:
IllegalArgumentException
- ifmax≤min
- See Also:
-
-
Method Details
-
getMin
public double getMin()Get the lower bound of the uniform distribution (inclusive).- Returns:
- the lower bound
-
getMax
public double getMax()Get the upper bound of the uniform distribution (exclusive).- Returns:
- the upper bound
-
getRange
public double getRange()Get the range of the uniform distribution.- Returns:
- the range of the interval
max-min
-
next
public double next()Generate a uniformly distributed random number from interval[min, max)
.- Returns:
- the uniformly distributed random number
-
clone
Description copied from class:RNGDistribution
Clone this RNGDistribution to ensure both objects return identical sequences of random numbers.IMPORTANT:
- Specified by:
clone
in classRNGDistribution
- Returns:
- clone of RNGDistribution
-
next
Uniformly distributed random number in[min, max)
using random number generatorrng
.Note: no performance difference between the instance method
next()
and this static counterpart.- Parameters:
rng
- random number generatormin
- lower bound of uniform interval (inclusive)max
- upper bound of uniform interval (exclusive)- Returns:
- uniformly distributed random number from interval
[min, max)
- Throws:
IllegalArgumentException
- ifmax≤min
-
test
Test Uniform 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 is0
. 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 min, double max) Helper method to calculate the cumulative distribution function,cdf
, of the Uniform distribution.- Parameters:
x
- the value for which to calculate thecdf
min
- the minimum valuemax
- the maximum value- Returns:
cdf
atx
-