The function may be called by the names: g05sec, nag_rand_dist_dirichlet or nag_rand_dirichlet.
The distribution has PDF (probability density function)
where is a vector of dimension , such that for all and .
g05sec generates a draw from a Dirichlet distribution by first drawing independent samples, , i.e., independent draws from a gamma distribution with parameters and one, and then setting .
One of the initialization functions g05kfc (for a repeatable sequence if computed sequentially) or g05kgc (for a non-repeatable sequence) must be called prior to the first call to g05sec.
Dagpunar J (1988) Principles of Random Variate Generation Oxford University Press
Hastings N A J and Peacock J B (1975) Statistical Distributions Butterworth
1: – Nag_OrderTypeInput
On entry: the order argument specifies the two-dimensional storage scheme being used, i.e., row-major ordering or column-major ordering. C language defined storage is specified by . See Section 3.1.3 in the Introduction to the NAG Library CL Interface for a more detailed explanation of the use of this argument.
2: – IntegerInput
On entry: , the number of pseudorandom numbers to be generated.
3: – IntegerInput
On entry: , the number of dimensions of the distribution.
4: – const doubleInput
On entry: the parameter vector for the distribution.
On entry: contains information on the selected base generator and its current state.
On exit: contains updated information on the state of the generator.
6: – doubleOutput
Note: the dimension, dim, of the array
must be at least
where appears in this document, it refers to the array element
On exit: the pseudorandom numbers from the specified Dirichlet distribution, with holding the th dimension for the th variate.
7: – IntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array x.
if , .
8: – NagError *Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).
6Error Indicators and Warnings
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
On entry, argument had an illegal value.
On entry, .
On entry, .
On entry, and .
On entry, and .
Constraint: or .
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
On entry, state vector has been corrupted or not initialized.
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.
On entry, at least one .
8Parallelism and Performance
g05sec is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this function. Please also consult the Users' Note for your implementation for any additional implementation-specific information.
This example prints a set of five pseudorandom numbers from a Dirichlet distribution with parameters and , generated by a single call to g05sec, after initialization by g05kfc.