Imath
<navlinks>
<page>

# Random Numbers

Functions to compute pseudo-random numbers.

    #include <Imath/ImathRandom.h>

template<class Vec, class Rand>
Vec Imath::solidSphereRand(Rand &rand)

  Return random points uniformly distributed in a sphere with radius 1 around the origin (distance from origin <= 1).

template<class Vec, class Rand>
Vec Imath::hollowSphereRand(Rand &rand)

  Return random points uniformly distributed on the surface of a sphere with radius 1 around the origin.

template<class Vec, class Rand>
Vec Imath::gaussSphereRand(Rand &rand)

  Return random points whose distance from the origin has a normal (Gaussian) distribution with zero mean and unit variance.

template<class Rand>
float Imath::gaussRand(Rand &rand)

  Return random numbers with a normal (Gaussian) distribution with zero mean and unit variance.

double Imath::erand48(unsigned short state[3])

  Generate double-precision floating-point values between 0.0 and 1.0:

  The exponent is set to 0x3ff, which indicates a value greater than or equal to 1.0, and less than 2.0. The 48 most significant bits of the significand (mantissa) are filled with pseudo-random bits generated by rand48Next(). The remaining 4 bits are a copy of the 4 most significant bits of the significand. This results in bit patterns between 0x3ff0000000000000 and 0x3fffffffffffffff, which correspond to uniformly distributed floating-point values between 1.0 and 1.99999999999999978. Subtracting 1.0 from those values produces numbers between 0.0 and 0.99999999999999978, that is, between 0.0 and 1.0-DBL_EPSILON.

double Imath::drand48()

  Return erand48()

long int Imath::nrand48(unsigned short state[3])

  Generate uniformly distributed integers between 0 and 0x7fffffff.

long int Imath::lrand48()

  Return nrand48()

void Imath::srand48(long int seed)

</page>