Hp web site - 3.4.1 NUMERICAL DISTRIBUTIONS 129 E. Other continuous distributions.

3.4.1 NUMERICAL DISTRIBUTIONS 129 E. Other continuous distributions. Let, us now consider briefly how to handle some other distributions that arise reasonably often in practice. (1) The gamma distribution of order a > 0 is defined by F(x) = & 1 f-1e-t dt, x 2 0. When a = 1, this is the exponential distribution with mean 1; when a = 4, it is the distribution of iZ2, where 2 has the normal distribution (mean 0, variance 1). If X and Y are independent gamma-distributed random variables, of order a and b, respectively, then X + Y has the gamma distribution of order a + b. Thus, for example, the sum of k independent exponential deviates with mean 1 has the gamma distribution of order k. If the logarithm method (32) is being used to generate these exponential deviates, we need compute only one logarithm: X t -ln(U1. . . Uk), where Ul, . . . , Uk are nonzero uniform deviates. This technique handles all integer orders a; to complete the picture, a suitable method for 0 < a < 1 appears in exercise 16. The simple logarithm method is much too slow when a is large, since it requires [al uniform deviates. For large a, the following algorithm due to J. H. Ahrens is reasonably efficient, and it is easy to write in terms of standard subroutines. Algorithm A (Gamma distribution of order a > 1). Al. [Generate candidate.] Set Y e tan(rU), where U is a uniform deviate, and set X t J-Y + a -1. (In place of tan(TU) we could use a polar method, e.g., &/VI in step P4 of Algorithm P.) A2. [Accept?] If X 5 0, return to Al. Otherwise generate a uniform deviate V, and return to Al if V > (1 + Y2) exp((a -1) ln(X/(a -1)) -d-Y>. Otherwise accept X. 1 The average number of times step Al is performed is < 1.902 when a 2 3. For further discussion, proof, and a slightly more complex method that is two to three times faster, see J. H. Ahrens and U. Dieter, Computing 12 (1974), 223-246. There is also an attractive approach for large a based on the remarkable fact that gamma deviates are approximately equal to aX3, where X is normally dis- tributed with mean 1 - 1/(9a) and standard deviation l/a; see G. Marsaglia, Computers and Math. 3 (1977), 321-325. (.2) The beta distribution with positive parameters a and b is defined by r(a+b) F(x) s05 =~ t+l(1 -Q-1 dt, O

Leave a Reply