Package org.anchoranalysis.core.random
Interface RandomNumberGenerator
- All Known Implementing Classes:
RandomNumberGeneratorMersenne
public interface RandomNumberGenerator
Generates random numbers from various distributions.
- Author:
- Owen Feehan
-
Method Summary
Modifier and TypeMethodDescriptioncern.jet.random.Normal
generateNormal
(double mean, double standardDeviation) Generates a Gaussian (Normal) random variable with particular parameterization.cern.jet.random.Poisson
generatePoisson
(double param) Generates a Poisson random variable with particular parameterization.default double
sampleDoubleFromRange
(double endExclusive) Generates a uniformly random floating-point number within a range from0
(exclusive) toendExclusive
.default double
sampleDoubleFromRange
(double startExclusive, double endExclusive) Generates a uniformly random floating-point number within a range.default double
sampleDoubleFromZeroCenteredRange
(double halfWidth) Generates a uniformly random floating-point number centered around0
ranging from[-halfWidth,+halfWidth]
(both exclusive).double
Samples from a uniformly-distributed range between 0.0 (exclusive) and 1.0 (exclusive).default <T> T
sampleFromList
(List<T> list) Samples uniformly an element from a list.default int
sampleIntFromRange
(int endExclusive) Generates a uniformly random discrete number within a range from 0 (inclusive) toendExclusive
.default int
sampleIntFromRange
(int startInclusive, int endExclusive) Samples from a uniformly random discrete number within a range.default long
sampleLongFromRange
(long endExclusive) Generates a uniformly random discrete number within a range from 0 (inclusive) toendExclusive
.
-
Method Details
-
sampleDoubleZeroAndOne
double sampleDoubleZeroAndOne()Samples from a uniformly-distributed range between 0.0 (exclusive) and 1.0 (exclusive).- Returns:
- the randomly-sampled number.
-
generatePoisson
cern.jet.random.Poisson generatePoisson(double param) Generates a Poisson random variable with particular parameterization.- Parameters:
param
- the single parameter for the distribution.- Returns:
- a random-distribution from which sampling can occur.
-
generateNormal
cern.jet.random.Normal generateNormal(double mean, double standardDeviation) Generates a Gaussian (Normal) random variable with particular parameterization.- Parameters:
mean
- mean parameter for the distributionstandardDeviation
- standard-deviation parameter for the distribution- Returns:
- a random-distribution from which sampling can occur.
-
sampleFromList
Samples uniformly an element from a list.- Type Parameters:
T
- type of elements in the list.- Parameters:
list
- the list to sample an element from.- Returns:
- a randomly-sampled element from the list.
-
sampleIntFromRange
default int sampleIntFromRange(int endExclusive) Generates a uniformly random discrete number within a range from 0 (inclusive) toendExclusive
.- Parameters:
endExclusive
- the final number in the range (excluded from consideration).- Returns:
- the randomly-sampled (discrete) number.
-
sampleLongFromRange
default long sampleLongFromRange(long endExclusive) Generates a uniformly random discrete number within a range from 0 (inclusive) toendExclusive
.- Parameters:
endExclusive
- the final number in the range (excluded from consideration)- Returns:
- the randomly-sampled (discrete) number
-
sampleDoubleFromRange
default double sampleDoubleFromRange(double endExclusive) Generates a uniformly random floating-point number within a range from0
(exclusive) toendExclusive
.- Parameters:
endExclusive
- the final number in the range (excluded from consideration).- Returns:
- the randomly-sampled number.
-
sampleIntFromRange
default int sampleIntFromRange(int startInclusive, int endExclusive) Samples from a uniformly random discrete number within a range.- Parameters:
startInclusive
- the starting number in the range (included).endExclusive
- the final number in the range (excluded from consideration).- Returns:
- the randomly-sampled (discrete) number.
-
sampleDoubleFromRange
default double sampleDoubleFromRange(double startExclusive, double endExclusive) Generates a uniformly random floating-point number within a range.- Parameters:
startExclusive
- the starting number in the range (excluded from consideration).endExclusive
- the final number in the range (excluded from consideration).- Returns:
- the randomly-sampled number.
-
sampleDoubleFromZeroCenteredRange
default double sampleDoubleFromZeroCenteredRange(double halfWidth) Generates a uniformly random floating-point number centered around0
ranging from[-halfWidth,+halfWidth]
(both exclusive).- Parameters:
halfWidth
- half the total width of the distribution (i.e. the width of one side)- Returns:
- the randomly-sampled number
-