g05se generates a vector of pseudorandom numbers taken from a Dirichlet distribution.

# Syntax

C#
```public static void g05se(
int n,
int m,
double[] a,
G05..::..G05State g05state,
double[,] x,
out int ifail
)```
Visual Basic
```Public Shared Sub g05se ( _
n As Integer, _
m As Integer, _
a As Double(), _
g05state As G05..::..G05State, _
x As Double(,), _
<OutAttribute> ByRef ifail As Integer _
)```
Visual C++
```public:
static void g05se(
int n,
int m,
array<double>^ a,
G05..::..G05State^ g05state,
array<double,2>^ x,
[OutAttribute] int% ifail
)```
F#
```static member g05se :
n : int *
m : int *
a : float[] *
g05state : G05..::..G05State *
x : float[,] *
ifail : int byref -> unit
```

#### Parameters

n
Type: System..::..Int32
On entry: $n$, the number of pseudorandom numbers to be generated.
Constraint: ${\mathbf{n}}\ge 0$.
m
Type: System..::..Int32
On entry: $m$, the number of dimensions of the distribution.
Constraint: ${\mathbf{m}}>0$.
a
Type: array<System..::..Double>[]()[][]
An array of size [m]
On entry: the parameter vector for the distribution.
Constraint: ${\mathbf{a}}\left[\mathit{i}-1\right]>0.0$, for $\mathit{i}=1,2,\dots ,{\mathbf{m}}$.
g05state
Type: NagLibrary..::..G05..::..G05State
An Object of type G05.G05State.
x
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, _tdx]
Note: dim1 must satisfy the constraint: $\mathrm{dim1}\ge {\mathbf{n}}$
On exit: the $n$ pseudorandom numbers from the specified Dirichlet distribution, with ${\mathbf{x}}\left[i-1,j-1\right]$ holding the $j$th dimension for the $i$th variate.
ifail
Type: System..::..Int32%
On exit: ${\mathbf{ifail}}={0}$ unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).

# Description

The distribution has PDF (probability density function)
 $fx=1Bα∏ i=1 m xiαi-1 andBα=∏ i=1 m ΓαiΓ∑ i=1 m αi$
where $x=\left\{{x}_{1},{x}_{2},\dots ,{x}_{m}\right\}$ is a vector of dimension $m$, such that ${x}_{i}>0$ for all $i$ and $\sum _{\mathit{i}=1}^{m}{x}_{i}=1$.
g05se generates a draw from a Dirichlet distribution by first drawing $m$ independent samples, ${y}_{i}\sim \mathrm{gamma}\left({\alpha }_{i},1\right)$, i.e., independent draws from a gamma distribution with parameters ${\alpha }_{i}>0$ and one, and then setting ${x}_{i}={y}_{i}/\sum _{\mathit{j}=1}^{m}{y}_{j}$.
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 g05se.

# References

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:
Some error messages may refer to parameters that are dropped from this interface (LDX) In these cases, an error in another parameter has usually caused an incorrect value to be inferred.
${\mathbf{ifail}}=1$
On entry, ${\mathbf{n}}<0$.
${\mathbf{ifail}}=2$
On entry, ${\mathbf{m}}<1$.
${\mathbf{ifail}}=3$
On entry, at least one ${\mathbf{a}}\left[\mathit{i}-1\right]\le 0.0$.
${\mathbf{ifail}}=4$
 On entry, state vector was not initialized or has been corrupted.
${\mathbf{ifail}}=6$
On entry, ${\mathbf{ldx}}<{\mathbf{n}}$.
${\mathbf{ifail}}=-9000$
An error occured, see message report.
${\mathbf{ifail}}=-6000$
Invalid Parameters $〈\mathit{\text{value}}〉$
${\mathbf{ifail}}=-4000$
Invalid dimension for array $〈\mathit{\text{value}}〉$
${\mathbf{ifail}}=-8000$
Negative dimension for array $〈\mathit{\text{value}}〉$
${\mathbf{ifail}}=-6000$
Invalid Parameters $〈\mathit{\text{value}}〉$

Not applicable.

None.