C# Class RandomOps.RanInt32

Pseudo-Random Number Generator (PRNG) base-class for a generator of UInt32 integers.
It is somewhat tricky to implement Index() using integer-operations and get the rounding right for all cases, so we reuse the base-class implementation which indirectly uses Uniform().
Inheritance: Random
Datei anzeigen Open project: DanWBR/dwsim3

Public Methods

Method Description
Bool ( ) : bool

Draw a random boolean with equal probability of true or false. Thread-safe if Rand() is thread-safe.

Byte ( ) : byte

Draw a random and uniform byte. Thread-safe if Rand() is thread-safe.

The least significant bits are not that statistically random, hence we must use the most significant bits by a bit-shift.

RanInt32 ( ) : System

Constructs the PRNG-object.

Rand ( ) : Int32

Draw a random number in inclusive range {0, .., RandMax}

Uniform ( ) : double

Draw a uniform random number in the exclusive range (0,1) Thread-safe if Rand() is thread-safe.

Assumes that Rand() is in {0, .., RandMax}.

Protected Methods

Method Description
Seed ( ) : void

Seed with the time of day.

Seed ( Int32 seed ) : void

Seed with an integer.

Method Details

Bool() public method

Draw a random boolean with equal probability of true or false. Thread-safe if Rand() is thread-safe.
public Bool ( ) : bool
return bool

Byte() public method

Draw a random and uniform byte. Thread-safe if Rand() is thread-safe.
The least significant bits are not that statistically random, hence we must use the most significant bits by a bit-shift.
public Byte ( ) : byte
return byte

RanInt32() public method

Constructs the PRNG-object.
public RanInt32 ( ) : System
return System

Rand() public abstract method

Draw a random number in inclusive range {0, .., RandMax}
public abstract Rand ( ) : Int32
return System.Int32

Seed() protected method

Seed with the time of day.
protected Seed ( ) : void
return void

Seed() protected abstract method

Seed with an integer.
protected abstract Seed ( Int32 seed ) : void
seed System.Int32
return void

Uniform() public method

Draw a uniform random number in the exclusive range (0,1) Thread-safe if Rand() is thread-safe.
Assumes that Rand() is in {0, .., RandMax}.
public Uniform ( ) : double
return double