g05sj generates a vector of pseudorandom numbers taken from a gamma distribution with parameters and .
Syntax
C# |
---|
public static void g05sj( int n, double a, double b, G05..::..G05State g05state, double[] x, out int ifail ) |
Visual Basic |
---|
Public Shared Sub g05sj ( _ n As Integer, _ a As Double, _ b As Double, _ g05state As G05..::..G05State, _ x As Double(), _ <OutAttribute> ByRef ifail As Integer _ ) |
Visual C++ |
---|
public: static void g05sj( int n, double a, double b, G05..::..G05State^ g05state, array<double>^ x, [OutAttribute] int% ifail ) |
F# |
---|
static member g05sj : n : int * a : float * b : float * g05state : G05..::..G05State * x : float[] * ifail : int byref -> unit |
Parameters
- n
- Type: System..::..Int32On entry: , the number of pseudorandom numbers to be generated.Constraint: .
- a
- Type: System..::..DoubleOn entry: , the parameter of the gamma distribution.Constraint: .
- b
- Type: System..::..DoubleOn entry: , the parameter of the gamma distribution.Constraint: .
- g05state
- Type: NagLibrary..::..G05..::..G05StateAn Object of type G05.G05State.
- x
- Type: array<System..::..Double>[]()[][]An array of size [n]On exit: the pseudorandom numbers from the specified gamma distribution.
- ifail
- Type: System..::..Int32%On exit: unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).
Description
The gamma distribution has PDF (probability density function)
One of three algorithms is used to generate the variates depending upon the value of :
(i) | if , a switching algorithm described by Dagpunar (1988) (called G6) is used. The target distributions are and , where , and the switching parameter, , is taken as . This is similar to Ahrens and Dieter's GS algorithm (see Ahrens and Dieter (1974)) in which ; |
(ii) | if , the gamma distribution reduces to the exponential distribution and the method based on the logarithmic transformation of a uniform random variate is used; |
(iii) | if , the algorithm given by Best (1978) is used. This is based on using a Student's -distribution with two degrees of freedom as the target distribution in an envelope rejection method. |
One of the initialization methods (G05KFF not in this release) (for a repeatable sequence if computed sequentially) or (G05KGF not in this release) (for a non-repeatable sequence) must be called prior to the first call to g05sj.
References
Ahrens J H and Dieter U (1974) Computer methods for sampling from gamma, beta, Poisson and binomial distributions Computing 12 223–46
Best D J (1978) Letter to the Editor Appl. Statist. 27 181
Dagpunar J (1988) Principles of Random Variate Generation Oxford University Press
Hastings N A J and Peacock J B (1975) Statistical Distributions Butterworth
Error Indicators and Warnings
Errors or warnings detected by the method:
- On entry, .
- On entry, .
- On entry, .
On entry, state vector was not initialized or has been corrupted.
Accuracy
Not applicable.
Parallelism and Performance
None.
Further Comments
None.