|
NAG[g05lec] NAG[nag_rngs_beta] - Generates a vector of random numbers from a distribution, seeds and generator number passed explicitly
|
|
Calling Sequence
g05lec(a, b, n, x, igen, iseed, 'fail'=fail)
nag_rngs_beta(. . .)
Parameters
|
a - float;
|
|
|
On entry: , the argument of the beta distribution.
|
|
Constraint: . .
|
|
|
b - float;
|
|
|
On entry: , the argument of the beta distribution.
|
|
Constraint: . .
|
|
|
n - integer;
|
|
|
On entry: , the number of pseudo-random numbers to be generated.
|
|
Constraint: . .
|
|
|
x - Vector(1..dim, datatype=float[8]);
|
|
|
Note: the dimension, dim, of the array x must be at least .
|
|
On exit: the pseudo-random numbers from the specified beta distribution.
|
|
|
iseed - Vector(1.. , datatype=integer[kernelopts('wordsize')/8]);
|
|
|
On entry: contains values which define the current state of the selected generator.
|
|
On exit: contains updated values defining the new state of the selected generator.
|
|
|
'fail'=fail - table; (optional)
|
|
|
The NAG error argument, see the documentation for NagError.
|
|
|
|
Description
|
|
|
Purpose
|
|
nag_rngs_beta (g05lec) generates a vector of pseudo-random numbers taken from a beta distribution with and .
|
|
Description
|
|
The beta distribution has PDF (probability density function)
One of four algorithms is used to generate the variates depending on the values of and . Let be the maximum and be the minimum of and . Then the algorithms are as follows:
|
If , the algorithm BB given by Cheng (1978) is used. This involves the generation of an observation from a beta distribution of the second kind by the envelope rejection method using a log-logistic target distribution and then transforming it to a beta variate;
|
One of the initialization functions g05kbc (nag_rngs_init_repeatable) (for a repeatable sequence if computed sequentially) or g05kcc (nag_rngs_init_nonrepeatable) (for a non-repeatable sequence) must be called prior to the first call to nag_rngs_beta (g05lec).
|
|
Error Indicators and Warnings
|
|
"NE_BAD_PARAM"
On entry, argument had an illegal value.
"NE_INT"
On entry, . Constraint: .
"NE_INTERNAL_ERROR"
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please consult NAG for assistance.
"NE_REAL"
On entry, . Constraint: .
On entry, . Constraint: .
|
|
Further Comments
|
|
To generate an observation, , from the beta distribution of the second kind from an observation, , generated by nag_rngs_beta (g05lec) the transformation, , may be used.
|
|
|
Examples
|
|
>
|
a := 2:
b := 2:
n := 5:
igen := 1:
x := Vector(5, datatype=float[8]):
iseed := Vector([1762543, 9324783, 42344, 742355], datatype=integer[kernelopts('wordsize')/8]):
NAG:-g05lec(a, b, n, x, igen, iseed):
|
|
|
See Also
|
|
Atkinson A C (1979) A family of switching algorithms for the computer generation of beta random variates Biometrika 66 141–5
Cheng R C H (1978) Generating beta variates with nonintegral shape parameters Comm. ACM 21 317–322
Dagpunar J (1988) Principles of Random Variate Generation Oxford University Press
Hastings N A J and Peacock J B (1975) Statistical Distributions Butterworths
g05 Chapter Introduction.
NAG Toolbox Overview.
NAG Web Site.
|
|