class OERandom

This class represents OERandom.

The OERandom class provides a portable pseudo-random number generator.


OERandom(bool timeseed=false)

The ‘timeseed’ argument to the OERandom constructor indicates whether the pseudo random number generator should initialize (or seed) its sequence from the system clock.


unsigned int GetSeed() const

Return the current state of the random number generator so that a new OERandom object can be created and restarted from the given state. To restart a OERandom object at a given location, pass this seed into OERandom.Seed.


The datatype of this method will likely change in a future release when a better random number generator will be implemented.


float NextFloat()

Returns the next pseudo-random floating point value in the range [0.0, 1.0). To convert this value into an integer range, for example 10 discrete values, use int i = (int)floor(10.0*r.NextFloat()), which should return values in the range 0 to 9 inclusive.


int NextInt()

Return the next random integer in this sequence of random numbers. The returned integer will never be negative.


void Seed(unsigned int seed)

Sets the pseudo random number generator seed to a given value. The OERandom class uses a deterministic linear congruential class of pseudo random number generator (PRNG). Setting the seed to a specific value, causes the sequence of subsequent OERandom.NextFloat values to be identical on all platforms. This may be useful for testing stochastic algorithms on different architectures/operating systems.


void TimeSeed()

Seeds this random number generator based upon the number of seconds since January 1, 1970, Coordinated Universal Time.