112 |
|
double rand53(); // real number in [0,1) |
113 |
|
|
114 |
|
// Access to nonuniform random number distributions |
115 |
< |
double randNorm( const double& mean = 0.0, const double& variance = 0.0 ); |
115 |
> |
double randNorm( const double mean = 0.0, const double variance = 0.0 ); |
116 |
|
|
117 |
|
// Re-seeding functions with same behavior as initializers |
118 |
|
void seed( const uint32 oneSeed ); |
180 |
|
return ( a * 67108864.0 + b ) * (1.0/9007199254740992.0); // by Isaku Wada |
181 |
|
} |
182 |
|
|
183 |
< |
inline double MTRand::randNorm( const double& mean, const double& variance ) |
183 |
> |
inline double MTRand::randNorm( const double mean, const double variance ) |
184 |
|
{ |
185 |
|
// Return a real number from a normal (Gaussian) distribution with given |
186 |
|
// mean and variance by Box-Muller method |
187 |
< |
double r = sqrt( -2.0 * log( 1.0-randDblExc()) ) * variance; |
187 |
> |
assert(variance > 0); |
188 |
> |
double r = sqrt( -2.0 * log( 1.0-randDblExc()) * variance); |
189 |
|
double phi = 2.0 * 3.14159265358979323846264338328 * randExc(); |
190 |
|
return mean + r * cos(phi); |
191 |
|
} |