C++ API Reference
MRandom Namespace 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...
 

Detailed Description

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.

Function Documentation

unsigned long long Rand ( unsigned long long  i,
unsigned long long  seed 
)

Generate a random number.

Parameters
[in]iRequested value from the sequence of random numbers.
[in]seedSeed value
Returns
. Random number
double Rand_d ( unsigned long long  i,
unsigned long long  seed 
)

Generate a uniform double in [0,1).

Parameters
[in]iRequested value from the sequence of random numbers.
[in]seedSeed value
Returns
. Random number
float Rand_f ( unsigned long long  i,
unsigned long long  seed 
)

Generate a uniform float in [0,1).

Parameters
[in]iRequested value from the sequence of random numbers.
[in]seedSeed value
Returns
. Random number
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.

Parameters
[in]iRequested value from the sequence of random numbers.
[in]seedSeed value
[in]rangeMinLower bound on the range of values.
[in]rangeMaxUpper bound on the range of values.
Returns
. Random number
void Rand_2f ( float  output[2],
unsigned long long  i,
unsigned long long  seed 
)

Generate two uniform floats in [0,1).

Parameters
[out]outputHolds two random numbers from the sequence.
[in]iRequested value from the sequence of random numbers.
[in]seedSeed value
void Rand_3f ( float  output[3],
unsigned long long  i,
unsigned long long  seed 
)

Generate three uniform floats in [0,1).

Parameters
[out]outputHolds three random numbers from the sequence.
[in]iRequested value from the sequence of random numbers.
[in]seedSeed value