The random number generator base class. More...
#include "murl_util_rng.h"
Public Member Functions | |
virtual | ~Rng ()=default |
The destructor. | |
virtual void | Seed (UInt32 seed)=0 |
Seed the random number generator. More... | |
virtual UInt32 | Rand ()=0 |
Get a random number in the full UInt32 range. More... | |
Bool | RandBool () |
Get a random Bool value. More... | |
UInt32 | RandUInt (UInt32 from, UInt32 to) |
Get a random UInt32 value within a specified range. More... | |
SInt32 | RandSInt (SInt32 from, SInt32 to) |
Get a random SInt32 value within a specified range. More... | |
Real | RandReal (Real from, Real to) |
Get a random Real value within a specified range. More... | |
Double | RandDouble (Double from, Double to) |
Get a random Double value within a specified range. More... | |
SInt32 | Draw (const UInt32Array &distribution) |
Draw an index from a distribution array. More... | |
SInt32 | DrawNoReplacement (UInt32Array &distribution) |
Draw an index from a distribution array with no replacement. More... | |
SInt32 | DrawNoReplacement (UInt32Array &distribution, UInt32 decrement) |
Draw an index from a distribution array with no replacement. More... | |
Protected Member Functions | |
Rng ()=default | |
The default constructor. | |
Detailed Description
The random number generator base class.
The base class is abstract and is implemented by the TT800, Well1024 and Marsaglia class.
Member Function Documentation
◆ Seed()
|
pure virtual |
Seed the random number generator.
- Parameters
-
seed The seed value.
Implemented in Murl::Util::Well1024, Murl::Util::TT800, and Murl::Util::Marsaglia.
◆ Rand()
|
pure virtual |
Get a random number in the full UInt32 range.
- Returns
- The random number.
Implemented in Murl::Util::Well1024, Murl::Util::TT800, and Murl::Util::Marsaglia.
◆ RandBool()
Bool Murl::Util::Rng::RandBool | ( | ) |
Get a random Bool value.
- Returns
- The random Bool value.
◆ RandUInt()
Get a random UInt32 value within a specified range.
It is supported to pass a range of from > to.
- Parameters
-
from The start of the range. to The end of the range.
- Returns
- The random UInt32 value in range [from .. to].
◆ RandSInt()
Get a random SInt32 value within a specified range.
It is supported to pass a range of from > to.
- Parameters
-
from The start of the range. to The end of the range.
- Returns
- The random SInt32 value in range [from .. to].
◆ RandReal()
Get a random Real value within a specified range.
Scales (from - to) within a 32 bit random number. It is supported to pass a range of from > to.
- Parameters
-
from The start of the range. to The end of the range.
- Returns
- The random Real value in range [from .. to].
◆ RandDouble()
Get a random Double value within a specified range.
Scales (from - to) within a 64 bit random number. It is supported to pass a range of from > to.
- Parameters
-
from The start of the range. to The end of the range.
- Returns
- The random Real value in range [from .. to].
◆ Draw()
SInt32 Murl::Util::Rng::Draw | ( | const UInt32Array & | distribution | ) |
Draw an index from a distribution array.
The distribution array contains numbers which are defining the probability of the partition. The higher the value of the partition, the higher is the probability of drawing the partition.
- Parameters
-
distribution An array of partitions.
- Returns
- The index of the drawn partition or -1 if all partitions are zero.
◆ DrawNoReplacement() [1/2]
SInt32 Murl::Util::Rng::DrawNoReplacement | ( | UInt32Array & | distribution | ) |
Draw an index from a distribution array with no replacement.
Draw() and set the drawn partition to zero.
- Parameters
-
distribution An array of partitions.
- Returns
- The index of the drawn partition or -1 if all partitions are zero.
◆ DrawNoReplacement() [2/2]
SInt32 Murl::Util::Rng::DrawNoReplacement | ( | UInt32Array & | distribution, |
UInt32 | decrement | ||
) |
Draw an index from a distribution array with no replacement.
Draw() and decrement the drawn partition by a specified value.
- Parameters
-
distribution An array of partitions. decrement The value to decrement the drawn partition. The drawn partition is set to zero if the decrement underflows the partition.
- Returns
- The index of the drawn partition or -1 if all partitions are zero.
The documentation for this class was generated from the following file:
- murl_util_rng.h