|
|
◆ _zignorm_r()
| void _zignorm_r |
( |
double |
mu, |
|
|
double |
sigma, |
|
|
double * |
r, |
|
|
int |
ii, |
|
|
double |
yy, |
|
|
int * |
irev |
|
) |
| |
Generate random numbers following normal distribution (Ziggurat method) (reverse communication version)
- Purpose
- This routine generates random numbers following normal distribution N(μ, σ^2).
The given uniform random numbers are transformed to the normal random numbers by Ziggurat method.
- Parameters
-
| [in] | mu | The parameter μ(mean) of the normal distribution N(μ, σ^2). |
| [in] | sigma | The parameter σ(standard deviation) of the normal distribution N(μ, σ^2). |
| [out] | r | Normal random number. |
| [in] | ii | irev = 1: The integer uniform random number should be given in the next call. Only the lowest 7 or 8 bits (specified by init_zignorm_r()) are used. |
| [in] | yy | irev = 2, 3: The uniform random number in the interval [0, 1) should be given in yy in the next call. |
| [in,out] | irev | Control variable for reverse communication.
[in] Before first call, irev should be initialized to zero. On succeeding calls, irev should not be altered.
[out] If irev is not zero, complete the following tasks and call this routine again without changing irev.
= 0: Computation finished.
= 1: User should set the integer uniform random number in ii. Do not alter any variables other than ii. = 2, 3: User should set the uniform random number in the interval [0, 1) in yy. Do not alter any variables other than yy. |
- Note
- This function should be initialized by init_zignorm_r() before generating random numbers. If this function is called without initialization, it will be automatically initialized with default parameter.
- Reference
- Yatsuji Tetsuaki, "Probability distribution random number generation method" 2nd ed., Pleiades Publishing, 2019. (Japanese book)
|