|
| Norm (BGFLOAT m=DEFAULT_m, BGFLOAT s=DEFAULT_s, uint32_t seed=DEFAULT_seed) |
|
virtual BGFLOAT | operator() (void) override |
|
void | seed (BGFLOAT m, BGFLOAT s, uint32_t seed) |
| Allow Norm re-seeding (with same behavior as initializers)
|
|
virtual void | seed (uint32_t seed) override |
|
virtual void | seed () override |
|
template<class Archive > |
void | serialize (Archive &archive) |
| Cereal serialization method.
|
|
Public Member Functions inherited from MTRand |
| MTRand (uint32_t oneSeed) |
|
| MTRand (uint32_t *const bigSeed, uint32_t seedLength=N) |
|
BGFLOAT | rand () |
|
BGFLOAT | rand (BGFLOAT n) |
|
BGFLOAT | randExc () |
|
BGFLOAT | randExc (BGFLOAT n) |
|
BGFLOAT | randDblExc () |
|
BGFLOAT | randDblExc (BGFLOAT n) |
|
uint32_t | randInt () |
|
uint32_t | randInt (uint32_t n) |
|
BGFLOAT | inRange (BGFLOAT min, BGFLOAT max) |
|
BGFLOAT | rand53 () |
|
BGFLOAT | randNorm (BGFLOAT mean=0.0, BGFLOAT variance=0.0) |
|
void | seed (uint32_t *const bigSeed, uint32_t seedLength=N) |
|
void | save (uint32_t *saveArray) const |
|
void | load (uint32_t *const loadArray) |
|
template<class Archive > |
void | serialize (Archive &archive) |
| Cereal serialization method.
|
|
Generate normally distributed random numbers.
This class allows you to create RNG objects that are independently seeded upon construction and return normally distributed random numbers.
This function generates normally distributed random numbers with mean of mu and standard deviation of sigma, using the polar method of Marsaglia and Bray, "A Convenient Method for
Generating Normal Variables", SIAM Rev., 6: 260-264 (1964).
The algorithm is as follows:
Generate two uniformly distributed numbers, U1 and U2.
Let Vi = 2*Ui-1 for i=1,2, and let W = V1*V1 + V2*V2.
If W > 1, go back to step 1. Otherwise, let
Y = sqrt(-2*ln(W)/W), X1 = V1*Y, and X2 = V2*Y. Then X1 and X2 are normally distributed with mean of 0 and variance of 1.
Random numbers with mean of mu and standard deviation of sigma
are calculated by: X_prime = mu + sigma X.
Note that numbers are generated in pairs. On odd-numbered calls to operator(), pairs are calculated. On even-numbered calls, the second value is returned.
Modified from norm.c, from xneuron3
Definition at line 57 of file Norm.h.