PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_rand_dist_dirichlet (g05se)
Purpose
nag_rand_dist_dirichlet (g05se) generates a vector of pseudorandom numbers taken from a Dirichlet distribution.
Syntax
Description
The distribution has PDF (probability density function)
where
is a vector of dimension
, such that
for all
and
.
nag_rand_dist_dirichlet (g05se) 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
nag_rand_init_repeat (g05kf) (for a repeatable sequence if computed sequentially) or
nag_rand_init_nonrepeat (g05kg) (for a non-repeatable sequence) must be called prior to the first call to
nag_rand_dist_dirichlet (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
Parameters
Compulsory Input Parameters
- 1:
– int64int32nag_int scalar
-
, the number of pseudorandom numbers to be generated.
Constraint:
.
- 2:
– double array
-
The parameter vector for the distribution.
Constraint:
, for .
- 3:
– int64int32nag_int array
-
Note: the actual argument supplied
must be the array
state supplied to the initialization routines
nag_rand_init_repeat (g05kf) or
nag_rand_init_nonrepeat (g05kg).
Contains information on the selected base generator and its current state.
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the dimension of the array
a.
, the number of dimensions of the distribution.
Constraint:
.
Output Parameters
- 1:
– int64int32nag_int array
-
Contains updated information on the state of the generator.
- 2:
– double array
-
The pseudorandom numbers from the specified Dirichlet distribution, with holding the th dimension for the th variate.
- 3:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
-
-
Constraint: .
-
-
Constraint: .
-
-
On entry, at least one .
-
-
On entry,
state vector has been corrupted or not initialized.
-
-
Constraint: .
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
Accuracy
Not applicable.
Further Comments
None.
Example
This example prints a set of five pseudorandom numbers from a Dirichlet distribution with parameters
and
, generated by a single call to
nag_rand_dist_dirichlet (g05se), after initialization by
nag_rand_init_repeat (g05kf).
Open in the MATLAB editor:
g05se_example
function g05se_example
fprintf('g05se example results\n\n');
seed = [int64(1762543)];
genid = int64(1);
subid = int64(1);
[state, ifail] = g05kf( ...
genid, subid, seed);
n = int64(5);
a = [2; 2; 2; 2];
[state, x, ifail] = g05se( ...
n, a, state);
disp('Variates');
disp(x);
g05se example results
Variates
0.3600 0.3138 0.0837 0.2426
0.2874 0.5121 0.1497 0.0509
0.2286 0.2190 0.3959 0.1566
0.1744 0.3961 0.2764 0.1530
0.1522 0.2845 0.2074 0.3559
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015