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


6.1.2 Generating Random Numbers

To generate uniformly distributed random numbers, the following functions can be used.

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 random number generator rng. If nn is less than 1, then negative error code QSMM_ERR_INVAL will be returned.

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 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 random number generator rng.

To seed a pseudorandom number generator, the following function can be used.

Function: void qsmm_rng_seed (qsmm_rng_t rng, int seed)

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