edu.rit.numeric
Class UniformPrng
- java.lang.Object
-
- edu.rit.numeric.DoublePrng
-
- edu.rit.numeric.UniformPrng
-
public class UniformPrng extends DoublePrng
Class UniformPrng provides a pseudorandom number generator (PRNG) that generates random numbers with a uniform(a,b) distribution. The probability density function is
f(x) = 1/(b − a), a ≤ x ≤ b
f(x) = 0, otherwiseEvery call of the next() method results in one call of the underlying uniform PRNG's nextDouble() method.
-
-
Constructor Summary
Constructors Constructor and Description UniformPrng(Random theUniformPrng, double a, double b)Construct a new uniform PRNG.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description doublenext()Returns the next random number.
-
-
-
Constructor Detail
-
UniformPrng
public UniformPrng(Random theUniformPrng, double a, double b)
Construct a new uniform PRNG.- Parameters:
theUniformPrng- The underlying uniform PRNG.a- Interval lower bound.b- Interval upper bound.- Throws:
java.lang.NullPointerException- (unchecked exception) Thrown if theUniformPrng is null.java.lang.IllegalArgumentException- (unchecked exception) Thrown if a ≥ b.
-
-
Method Detail
-
next
public double next()
Returns the next random number.- Specified by:
nextin classDoublePrng- Returns:
- Random number.
-
-
DMelt 3.0 © DataMelt by jWork.ORG