![]() |
Murl Engine API
Version 2018.3
|
The random number generator base class. More...
#include <murl_util_rng.h>
The random number generator base class.
The base class is abstract and is implemented by the TT800, Well1024 and Marsaglia class.
Public Member Functions | |
virtual | ~Rng () |
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 () | |
The default constructor. | |
|
pure virtual |
Seed the random number generator.
seed | The seed value. |
Implemented in Murl::Util::Well1024, Murl::Util::TT800, and Murl::Util::Marsaglia.
|
pure virtual |
Get a random number in the full UInt32 range.
Implemented in Murl::Util::Well1024, Murl::Util::TT800, and Murl::Util::Marsaglia.
Bool Murl::Util::Rng::RandBool | ( | ) |
Get a random Bool value.
Get a random UInt32 value within a specified range.
It is supported to pass a range of from > to.
from | The start of the range. |
to | The end of the range. |
Get a random SInt32 value within a specified range.
It is supported to pass a range of from > to.
from | The start of the range. |
to | The end of the range. |
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.
from | The start of the range. |
to | The end of the range. |
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.
from | The start of the range. |
to | The end of the range. |
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.
distribution | An array of partitions. |
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.
distribution | An array of partitions. |
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.
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. |