Package org.uncommons.maths.random
Class ExponentialGenerator
- java.lang.Object
-
- org.uncommons.maths.random.ExponentialGenerator
-
- All Implemented Interfaces:
NumberGenerator<java.lang.Double>
public class ExponentialGenerator extends java.lang.Object implements NumberGenerator<java.lang.Double>
Continuous random sequence that follows an exponential distribution.- Since:
- 1.0.2
-
-
Field Summary
Fields Modifier and Type Field Description private NumberGenerator<java.lang.Double>
rate
private java.util.Random
rng
-
Constructor Summary
Constructors Constructor Description ExponentialGenerator(double rate, java.util.Random rng)
Creates a generator of exponentially-distributed values from a distribution with the specified rate.ExponentialGenerator(NumberGenerator<java.lang.Double> rate, java.util.Random rng)
Creates a generator of exponentially-distributed values from a distribution with a rate controlled by the specified generator parameter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Double
nextValue()
Generate the next exponential value from the current value of rate.
-
-
-
Field Detail
-
rate
private final NumberGenerator<java.lang.Double> rate
-
rng
private final java.util.Random rng
-
-
Constructor Detail
-
ExponentialGenerator
public ExponentialGenerator(NumberGenerator<java.lang.Double> rate, java.util.Random rng)
Creates a generator of exponentially-distributed values from a distribution with a rate controlled by the specified generator parameter. The mean of this distribution is 1 / rate and the variance is 1 / rate^2.- Parameters:
rate
- A number generator that provides values to use as the rate for the exponential distribution. This generator must only return non-zero, positive values.rng
- The source of randomness used to generate the exponential values.
-
ExponentialGenerator
public ExponentialGenerator(double rate, java.util.Random rng)
Creates a generator of exponentially-distributed values from a distribution with the specified rate. The mean of this distribution is 1 / rate and the variance is 1 / rate^2.- Parameters:
rate
- The rate (lamda) of the exponential distribution.rng
- The source of randomness used to generate the exponential values.
-
-
Method Detail
-
nextValue
public java.lang.Double nextValue()
Generate the next exponential value from the current value of rate.- Specified by:
nextValue
in interfaceNumberGenerator<java.lang.Double>
- Returns:
- The next exponentially-distributed value.
-
-