Generating Gamma-distributed Random Variables
Given the scaling property above, it is enough to generate gamma variables with as we can later convert to any value of with simple division.
Using the fact that a distribution is the same as an distribution, and noting the method of generating exponential variables, we conclude that if is uniformly distributed on, then − is distributed Now, using the "α-addition" property of gamma distribution, we expand this result:
where are all uniformly distributed on and independent. All that is left now is to generate a variable distributed as for and apply the "α-addition" property once more. This is the most difficult part.
Random generation of gamma variates is discussed in detail by Devroye, noting that none are uniformly fast for all shape parameters. For small values of the shape parameter, the algorithms are often not valid. For arbitrary values of the shape parameter, one can apply the Ahrens and Dieter modified acceptance-rejection method Algorithm GD (shape k ≥ 1), or transformation method when 0 < k < 1. Also see Cheng and Feast Algorithm GKM 3 or Marsaglia's squeeze method.
The following is a version of the Ahrens-Dieter acceptance-rejection method:
- Let be 1.
- Generate, and as independent uniformly distributed on variables.
- If, where, then go to step 4, else go to step 5.
- Let . Go to step 6.
- Let .
- If, then increment and go to step 2.
- Assume to be the realization of .
A summary of this is
where
- is the integral part of ,
- has been generated using the algorithm above with (the fractional part of ),
- and are distributed as explained above and are all independent.
Read more about this topic: Gamma Distribution
Famous quotes containing the words random and/or variables:
“... the random talk of people who have no chance of immortality and thus can speak their minds out has a setting, often, of lights, streets, houses, human beings, beautiful or grotesque, which will weave itself into the moment for ever.”
—Virginia Woolf (18821941)
“Science is feasible when the variables are few and can be enumerated; when their combinations are distinct and clear. We are tending toward the condition of science and aspiring to do it. The artist works out his own formulas; the interest of science lies in the art of making science.”
—Paul Valéry (18711945)