GClasses
|
This is a 64-bit pseudo-random number generator.
When subclassing it, overriding the next and setSeed methods will be sufficient. However, all of the methods are virtual, so you can give them more efficient or accurate versions if you wish.
#include <GRand.h>
Public Member Functions | |
GRand (uint64_t seed) | |
Create a new random number generator with the given seed. More... | |
GRand (const GRand &that) | |
Copy constructor. Throws an exception to prevent copying this object by value. More... | |
virtual | ~GRand () |
Destructor. More... | |
f (x;\alpha,\beta)& | |
Returns a random value from a beta distribution with parameters alpha and beta. More... | |
virtual uint64_t | next () |
Returns an unsigned pseudo-random 64-bit value. More... | |
virtual uint64_t | next (uint64_t range) |
Returns a pseudo-random uint from a discrete uniform distribution in the range 0 to range-1 (inclusive). (This method guarantees the result will be drawn from a uniform distribution, whereas doing "next() % range" does not guarantee a truly uniform distribution.) More... | |
virtual void | setSeed (uint64_t seed) |
Sets the seed. More... | |
Public Attributes | |
x | |
Protected Attributes | |
uint64_t | m_a |
uint64_t | m_b |
GClasses::GRand::GRand | ( | uint64_t | seed | ) |
Create a new random number generator with the given seed.
seed | the seed to use for generating numbers from the random number generator |
GClasses::GRand::GRand | ( | const GRand & | that | ) |
Copy constructor. Throws an exception to prevent copying this object by value.
|
virtual |
Destructor.
GClasses::GRand::f | ( | x;\ | alpha, |
\ | beta | ||
) |
Returns a random value from a beta distribution with parameters alpha and beta.
(The following was pasted from wikipedia with a little editing)
The probability density function of the beta distribution is:
|
inlinevirtual |
Returns an unsigned pseudo-random 64-bit value.
|
virtual |
Returns a pseudo-random uint from a discrete uniform distribution in the range 0 to range-1 (inclusive). (This method guarantees the result will be drawn from a uniform distribution, whereas doing "next() % range" does not guarantee a truly uniform distribution.)
range | one greater than the largest number that will be returned |
|
virtual |
Sets the seed.
|
protected |
|
protected |