Back to class index

Class LCG

Summary

A linear congruential random number generator.

Description

Uses D.H. Lehmer's Linear Congruential Method (1949) for generating random numbers. Supports both Multiplicative Congruential Method (increment==0) and Mixed Congruential Method (increment!=0) It is perhaps the simplest and fastest method to generate pseudo-random numbers on a computer. Per default uses the values for Minimal Standard LCG. http://en.wikipedia.org/wiki/Linear_congruential_generatorhttp://www.math.rutgers.edu/~greenfie/currentcourses/sem090/pdfstuff/jp.pdf

Pros:

Cons:

Member Reference

LCGA linear congruential random number generator.
multiplier
increment
modulus
lastNumber
ctor (+1 overload)Initializes the generator from the current system clock.
Seed(...)Reinitializes the generator to the new settings.
Int()Returns a random integer picked uniformly in the range [0, MaxInt()].
MaxInt()[const]Returns the biggest number the generator can yield. (Which is always modulus-1)
IntFast()Returns a random integer picked uniformly in the range [0, 2^32-1].
Int(a,b)Returns a random integer picked uniformly in the range [a, b].
Float()Returns a random float picked uniformly in the range [0, 1[.
Float01Incl()Returns a random float picked uniformly in the range [0, 1].
FloatNeg1_1()Returns a random float picked uniformly in the range ]-1, 1[.
Float(a,b)Returns a random float picked uniformly in the range [a, b[.
FloatIncl(a,b)Returns a random float picked uniformly in the range [a, b].
Back to class index