Authors

Citation

G. Marsaglia et Ww. Tsang, A simple method for generating gamma variables, ACM T MATH, 26(3), 2000, pp. 363-372

Citations number

14

Language

INGLESE

art.tipo

Article

Categorie Soggetti

Computer Science & Engineering

Journal title

ACM TRANSACTIONS ON MATHEMATICAL SOFTWARE

ISSN journal

0098-3500
→ ACNP

Volume

26

Issue

3

Year of publication

2000

Pages

363 - 372

Database

ISI

SICI code

0098-3500(200009)26:3<363:ASMFGG>2.0.ZU;2-L

Abstract

We offer a procedure for generating a gamma variate as the cube of a suitab
ly scaled normal variate. It is fast and simple, assuming one has a fast wa
y to generate normal variables. In brief: generate a normal variate x and a
uniform variate U until ln(U) < 0.5x(2) + d - dv + dln(v), then return dv.
Here, the gamma parameter is <alpha> greater than or equal to 1, and v = (
1 + x/ root 9d)(3), with d = alpha - 1/3. The efficiency is high, exceeding
0.951, 0.981, 0.992, 0.996 at alpha = 1, 2, 4, 8. The procedure can be mad
e to run faster by means of a simple squeeze that avoids the two logarithms
most of the time: return dv if U < 1 - 0.0331x(4). We give a short C progr
am for any <alpha> greater than or equal to 1, and show how to boost an alp
ha < 1 into an <alpha> > 1. The gamma procedure is particularly fast for C
implementation if the normal variate is generated in-line, via the #define
feature. We include such an inline version, leased on our ziggurat method.
With it, and an inline uniform generator, gamma variates can be produced in
400MHz CPUs at better than 1.3 million per second, with the parameter alph
a changing from call to call.