C++ API Reference
|
Methods for generating random numbers. More...
Functions | |
OPENMAYA_EXPORT unsigned long long | Rand (unsigned long long i, unsigned long long seed) |
Generate a random number. More... | |
OPENMAYA_EXPORT double | Rand_d (unsigned long long i, unsigned long long seed) |
Generate a uniform double in [0,1). More... | |
OPENMAYA_EXPORT float | Rand_f (unsigned long long i, unsigned long long seed) |
Generate a uniform float in [0,1). More... | |
OPENMAYA_EXPORT float | Rand_f (unsigned long long i, unsigned long long seed, float rangeMin, float rangeMax) |
Generate a uniform float within a given range of values. More... | |
OPENMAYA_EXPORT void | Rand_2f (float output[2], unsigned long long i, unsigned long long seed) |
Generate two uniform floats in [0,1). More... | |
OPENMAYA_EXPORT void | Rand_3f (float output[3], unsigned long long i, unsigned long long seed) |
Generate three uniform floats in [0,1). More... | |
Methods for generating random numbers.
The MRandom class implements several methods to generate sequences of random numbers.
For a given fixed seed, input i produces the i'th random number of a 2^64-long pseudo-random sequence. Different seeds will give different sequences, but nearby seeds may on rare occasion exhibit statistical correlations; it is therefore best to use hashed seeds.
All methods are thread-safe, values can be requested in any order, and sequences are repeatable.
unsigned long long Rand | ( | unsigned long long | i, |
unsigned long long | seed | ||
) |
Generate a random number.
[in] | i | Requested value from the sequence of random numbers. |
[in] | seed | Seed value |
double Rand_d | ( | unsigned long long | i, |
unsigned long long | seed | ||
) |
Generate a uniform double in [0,1).
[in] | i | Requested value from the sequence of random numbers. |
[in] | seed | Seed value |
float Rand_f | ( | unsigned long long | i, |
unsigned long long | seed | ||
) |
Generate a uniform float in [0,1).
[in] | i | Requested value from the sequence of random numbers. |
[in] | seed | Seed value |
float Rand_f | ( | unsigned long long | i, |
unsigned long long | seed, | ||
float | rangeMin, | ||
float | rangeMax | ||
) |
Generate a uniform float within a given range of values.
[in] | i | Requested value from the sequence of random numbers. |
[in] | seed | Seed value |
[in] | rangeMin | Lower bound on the range of values. |
[in] | rangeMax | Upper bound on the range of values. |
void Rand_2f | ( | float | output[2], |
unsigned long long | i, | ||
unsigned long long | seed | ||
) |
Generate two uniform floats in [0,1).
[out] | output | Holds two random numbers from the sequence. |
[in] | i | Requested value from the sequence of random numbers. |
[in] | seed | Seed value |
void Rand_3f | ( | float | output[3], |
unsigned long long | i, | ||
unsigned long long | seed | ||
) |
Generate three uniform floats in [0,1).
[out] | output | Holds three random numbers from the sequence. |
[in] | i | Requested value from the sequence of random numbers. |
[in] | seed | Seed value |