bcds.tools.random
Class RndNormal
java.lang.Object
bcds.tools.random.RndGenBase
bcds.tools.random.RndNormal
- All Implemented Interfaces:
- RndGen
public class RndNormal
- extends RndGenBase
- implements RndGen
Generates random values following a normal or "Gaussian" distribution
with given mean and standard deviation.
This code is an adaptation of several examples that can be found
on the internet.
- Author:
- Juan Segovia S.
Constructor Summary |
RndNormal(double mean,
double sigma)
Creates a new instance with specific desired mean and
standard deviation (sigma ). |
RndNormal(java.util.Random rnd,
double mean,
double sigma)
Creates a new instance with specific desired mean and
standard deviation (sigma ), with the randomness source
set to rnd . |
Method Summary |
double |
next()
Returns a random value drawn from a Gaussian distribution. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
RndNormal
public RndNormal(double mean,
double sigma)
- Creates a new instance with specific desired
mean
and
standard deviation (sigma
). The randomness source
is the default.
RndNormal
public RndNormal(java.util.Random rnd,
double mean,
double sigma)
- Creates a new instance with specific desired
mean
and
standard deviation (sigma
), with the randomness source
set to rnd
.
next
public double next()
- Returns a random value drawn from a Gaussian distribution.
Note that the returned value may be negative.
- Specified by:
next
in interface RndGen