XLPack 7.0
XLPack Numerical Library (C API) Reference Manual
Loading...
Searching...
No Matches

◆ zigexp_r()

void zigexp_r ( double  theta,
double *  r,
int  ii,
double  yy,
int *  irev 
)

Generate random numbers following exponential distribution (Ziggurat method) (reverse communication version)

Purpose
This routine generates random numbers following exponential distribution Exp(θ).
The given uniform random numbers are transformed to the exponential random numbers by Ziggurat method.
Parameters
[in]thetaThe parameter θ of the exponential distribution Exp(θ).
[out]rExponential random number (>= 0).
[in]iiirev = 1: The integer uniform random number should be given in the next call. Only the lowest 7 or 8 bits (specified by init_zigexp_r()) are used.
[in]yyirev = 2 to 4: The uniform random number in the interval [0, 1) should be given in yy in the next call.
[in,out]irevControl 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_zigexp_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)