Generates a pseudorandom number from a standard gamma distribution.

Namespace: Imsl.Stat
Assembly: ImslCS (in ImslCS.dll) Version: 6.5.0.0

Syntax

C#
public virtual double NextGamma(
	double a
)
Visual Basic (Declaration)
Public Overridable Function NextGamma ( _
	a As Double _
) As Double
Visual C++
public:
virtual double NextGamma(
	double a
)

Parameters

a
Type: System..::.Double
A double which specifies the shape parameter of the gamma distribution. It must be positive.

Return Value

A double which specifies a pseudorandom number from a standard gamma distribution.

Remarks

Method NextGamma generates pseudorandom numbers from a gamma distribution with shape parameter a. The probability density function is

P = \frac{1}{{\Gamma \left( a 
            \right)}}\int_o^x {e^{ - t} } t^{a - 1} dt

Various computational algorithms are used depending on the value of the shape parameter a. For the special case of a = 0.5, squared and halved normal deviates are used; and for the special case of a = 1.0, exponential deviates (from method NextExponential) are used. Otherwise, if a is less than 1.0, an acceptance-rejection method due to Ahrens, described in Ahrens and Dieter (1974), is used; if a is greater than 1.0, a ten-region rejection procedure developed by Schmeiser and Lal (1980) is used.

The Erlang distribution is a standard gamma distribution with the shape parameter having a value equal to a positive integer; hence, NextGamma generates pseudorandom deviates from an Erlang distribution with no modifications required.

See Also