naginterfaces.library.rand.dist_beta¶
- naginterfaces.library.rand.dist_beta(n, a, b, statecomm)[source]¶
dist_beta
generates a vector of pseudorandom numbers taken from a beta distribution with parameters and .For full information please refer to the NAG Library document for g05sb
https://support.nag.com/numeric/nl/nagdoc_30.3/flhtml/g05/g05sbf.html
- Parameters
- nint
, the number of pseudorandom numbers to be generated.
- afloat
, the parameter of the beta distribution.
- bfloat
, the parameter of the beta distribution.
- statecommdict, RNG communication object, modified in place
RNG communication structure.
This argument must have been initialized by a prior call to
init_repeat()
orinit_nonrepeat()
.
- Returns
- xfloat, ndarray, shape
The pseudorandom numbers from the specified beta distribution.
- Raises
- NagValueError
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, [‘state’] vector has been corrupted or not initialized.
- Notes
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 , Johnk’s algorithm is used, see for example Dagpunar (1988). This generates the beta variate as , where and are uniformly distributed random variates;
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;
if and , the switching algorithm given by Atkinson (1979) is used. The two target distributions used are and , along with the approximation to the switching parameter of ;
in all other cases, Cheng’s BC algorithm (see Cheng (1978)) is used with modifications suggested by Dagpunar (1988). This algorithm is similar to BB, used when , but is tuned for small values of and .
One of the initialization functions
init_repeat()
(for a repeatable sequence if computed sequentially) orinit_nonrepeat()
(for a non-repeatable sequence) must be called prior to the first call todist_beta
.
- References
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, Butterworth