XLPack 6.1
C/C++ API Reference Manual
Loading...
Searching...
No Matches

◆ _zignorm()

double _zignorm ( int(*)()  iurand,
double(*)()  durand,
double  mu,
double  sigma 
)

Generate random numbers following normal distribution (Ziggurat method)

Purpose
This routine generates random numbers following normal distribution N(μ, σ^2).
Uniform random numbers are generated by the given uniform random number generator. Then they are transformed to the normal random numbers by Ziggurat method.
Returns
Normal random number.
Parameters
[in]iurandThe user supplied integer uniform random number generator defined as follows.
int iurand(void)
{
return (an integer random number);
}
Only the lowest 7 or 8 bits (specified by init_zigexp()) are used.
[in]durandThe user supplied real uniform random number generator in the interval [0, 1) defined as follows.
double durand(void)
{
return (a real random number);
}
The real uniform random number generated by using this function is transformed to the exponential random number.
[in]muThe parameter μ(mean) of the normal distribution N(μ, σ^2).
[in]sigmaThe parameter σ(standard deviation) of the normal distribution N(μ, σ^2).
Note
This function should be initialized by init_zignorm() 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)