cxsrandlib
|
This library implements a seeded xorshift pseudorandom number generator. More...
Go to the source code of this file.
Functions | |
uint32_t | cxsrandlib_u32 (uint32_t *state) |
Return a seeded pseudorandom unsigned 32 bit integer. More... | |
int32_t | cxsrandlib_i32_range (int32_t lo, int32_t bound, uint32_t xorbits, uint32_t *state) |
Return a seeded pseudorandom signed 32 bit integer in the range [lo, bound). More... | |
uint32_t | cxsrandlib_u32_range (uint32_t lo, uint32_t bound, uint32_t xorbits, uint32_t *state) |
Return a seeded pseudorandom unsigned 32 bit integer in the range [lo, bound). More... | |
double | cxsrandlib_double (uint32_t *state) |
Return a seeded pseudorandom double in the range [0, 1]. More... | |
void | cxsrandlib_normal2 (double mean, double stddev, double out[2], uint32_t *state) |
Output two seeded pseudorandom doubles according to the normal distribution specified by mean and stddev using the Marsaglia polar method. More... | |
double | cxsrandlib_normal (double mean, double stddev, uint32_t *state) |
Return a seeded pseudorandom double according to the normal distribution specified by mean and stddev using the Marsaglia polar method. More... | |
This library implements a seeded xorshift pseudorandom number generator.
uint32_t cxsrandlib_u32 | ( | uint32_t * | state | ) |
Return a seeded pseudorandom unsigned 32 bit integer.
[in,out] | state | Seeded state (must be initialized non-zero) |
int32_t cxsrandlib_i32_range | ( | int32_t | lo, |
int32_t | bound, | ||
uint32_t | xorbits, | ||
uint32_t * | state | ||
) |
Return a seeded pseudorandom signed 32 bit integer in the range [lo, bound).
Results returned are uniform except with regard to modulo bias. If bound is less than or equal to lo, lo is returned and state is unmodified.
[in] | lo | Inclusive lower bound |
[in] | bound | Exclusive upper bound |
[in] | xorbits | Transform result before bounds adjustment is applied |
[in,out] | state | Seeded state (must be initialized non-zero) |
uint32_t cxsrandlib_u32_range | ( | uint32_t | lo, |
uint32_t | bound, | ||
uint32_t | xorbits, | ||
uint32_t * | state | ||
) |
Return a seeded pseudorandom unsigned 32 bit integer in the range [lo, bound).
Results returned are uniform except with regard to modulo bias. If bound is less than or equal to lo, lo is returned and state is unmodified.
[in] | lo | Inclusive lower bound |
[in] | bound | Exclusive upper bound |
[in] | xorbits | Transform result before bounds adjustment is applied |
[in,out] | state | Seeded state (must be initialized non-zero) |
double cxsrandlib_double | ( | uint32_t * | state | ) |
Return a seeded pseudorandom double in the range [0, 1].
[in,out] | state | Seeded state (must be initialized non-zero) |
void cxsrandlib_normal2 | ( | double | mean, |
double | stddev, | ||
double | out[2], | ||
uint32_t * | state | ||
) |
Output two seeded pseudorandom doubles according to the normal distribution specified by mean and stddev using the Marsaglia polar method.
This function has a cycle limited fallback to prevent theoretical infinite recursion.
[in] | mean | Mean of the normal distribution |
[in] | stddev | Standard deviation of the normal distribution |
[out] | out | Array in which to output two doubles |
[in,out] | state | Seeded state (must be initialized non-zero) |
double cxsrandlib_normal | ( | double | mean, |
double | stddev, | ||
uint32_t * | state | ||
) |
Return a seeded pseudorandom double according to the normal distribution specified by mean and stddev using the Marsaglia polar method.
This function operates by calling cxsrandlib_normal2 and discarding one of the outputs.
[in] | mean | Mean of the normal distribution |
[in] | stddev | Standard deviation of the normal distribution |
[in,out] | state | Seeded state (must be initialized non-zero) |