home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Geek Gadgets 1
/
ADE-1.bin
/
ade-dist
/
octave-1.1.1p1-src.tgz
/
tar.out
/
fsf
/
octave
/
libcruft
/
ranlib
/
gengam.f
< prev
next >
Wrap
Text File
|
1996-09-28
|
2KB
|
61 lines
REAL FUNCTION gengam(a,r)
C**********************************************************************
C
C REAL FUNCTION GENGAM( A, R )
C GENerates random deviates from GAMma distribution
C
C
C Function
C
C
C Generates random deviates from the gamma distribution whose
C density is
C (A**R)/Gamma(R) * X**(R-1) * Exp(-A*X)
C
C
C Arguments
C
C
C A --> Location parameter of Gamma distribution
C REAL A
C
C R --> Shape parameter of Gamma distribution
C REAL R
C
C
C Method
C
C
C Renames SGAMMA from TOMS as slightly modified by BWB to use RANF
C instead of SUNIF.
C
C For details see:
C (Case R >= 1.0)
C Ahrens, J.H. and Dieter, U.
C Generating Gamma Variates by a
C Modified Rejection Technique.
C Comm. ACM, 25,1 (Jan. 1982), 47 - 54.
C Algorithm GD
C
C (Case 0.0 <= R <= 1.0)
C Ahrens, J.H. and Dieter, U.
C Computer Methods for Sampling from Gamma,
C Beta, Poisson and Binomial Distributions.
C Computing, 12 (1974), 223-246/
C Adapted algorithm GS.
C
C**********************************************************************
C .. Scalar Arguments ..
REAL a,r
C ..
C .. External Functions ..
REAL sgamma
EXTERNAL sgamma
C ..
C .. Executable Statements ..
gengam = sgamma(r)
gengam = gengam/a
RETURN
END