Class C5Random

A modern random number generator based on G. Marsaglia: Seeds for Random Number Generators, Communications of the ACM 46, 5 (May 2003) 90-93; and a posting by Marsaglia to comp.lang.c on 2003-04-03.


object, System.Random

Constructor overview

C5Random() ,
C5Random(System.Int64 seed) ,
C5Random(System.UInt32[] Q)

Method overview

Equals(object obj), Inherited from object ,
Finalize(), Inherited from object ,
GetHashCode(), Inherited from object ,
GetType(), Inherited from object ,
MemberwiseClone(), Inherited from object ,
Next() ,
Next(int max) ,
Next(int min, int max) ,
NextBytes(byte[] buffer) ,
NextDouble() ,
Sample() ,
ToString(), Inherited from object

Constructor details

C5Random() Create a random number generator seed by system time.
C5Random(System.Int64 seed) Create a random number generator with a given seed
System.ArgumentExceptionIf seed is zero
seed:The seed
C5Random(System.UInt32[] Q) Create a random number generator with a specified internal start state.
System.ArgumentExceptionIf Q is not of length exactly 16
Q:The start state. Must be a collection of random bits given by an array of exactly 16 uints.

Method details

int Next() Get a new random System.Int32 value
Returns:The random int
int Next(int max) Get a random non-negative integer less than a given upper bound
System.ArgumentExceptionIf max is negative
max:The upper bound (exclusive)
int Next(int min, int max) Get a random integer between two given bounds
System.ArgumentExceptionIf max is less than min
min:The lower bound (inclusive)
max:The upper bound (exclusive)
void NextBytes(byte[] buffer) Fill a array of byte with random bytes
buffer:The array to fill
double NextDouble() Get a new random System.Double value
Returns:The random double
P double Sample() Get a new random System.Double value
Returns:The random double