Next: , Previous: , Up: Random Number Generators   [Contents][Index]


6.1.2 Generating Random Numbers

Use the following functions to generate uniformly distributed random numbers.

Function: int qsmm_rng_uniform_int (qsmm_rng_t rng, int nn)

This function returns a new integer random number uniformly distributed in the range 0 (inclusive) to nn (exclusive) produced using a random number generator rng. If nn is less than 1, the function returns negative error code QSMM_ERR_INVAL.

Function: double qsmm_rng_uniform (qsmm_rng_t rng)

This function returns a new random number uniformly distributed in the range 0 (inclusive) to 1 (exclusive) produced using a random number generator rng.

Function: double qsmm_rng_uniform_pos (qsmm_rng_t rng)

This function returns a new positive random number uniformly distributed in the range 0 to 1 (exclusive) produced using a random number generator rng.

Use the following function to seed a pseudo-random number generator.

Function: void qsmm_rng_seed (qsmm_rng_t rng, int seed)

This function seeds a pseudo-random number generator rng using seed. A seed specifies a stream of pseudo-random numbers produced by the generator. A random number generator created on the basis of a user-supplied function might not support seeding.