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

◆ rgama()

double rgama ( double(*)()  durand,
double(*)()  dnrand,
double  alpha,
double  beta 
)

Generate random numbers following gamma distribution (Squeeze method of Marsaglia and Tsang)

Purpose
This routine generates random numbers following gamma distribution Γ(α, β).
Normal and uniform random numbers are generated by the given random number generators. Then they are transformed to the gamma random numbers by the squeeze method of Marsaglia and Tsang.
Returns
Gamma random number. (> 0)
If alpha or beta is not valid, 0 will be returned.
Parameters
[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);
}
[in]dnrandThe user supplied real standard normal random number generator defined as follows.
double dnrand(void)
{
return (a real standard normal random number);
}
The real normal random number generated by using this function is transformed to the gamma random number.
[in]alphaThe shape parameter α of the gamma distribution Γ(α, β). (α > 0)
[in]betaThe rate parameter β of the gamma distribution Γ(α, β). (β > 0)
Reference
Yatsuji Tetsuaki, "Probability distribution random number generation method" 2nd ed., Pleiades Publishing, 2019. (Japanese book)