Title: | The Beta Random Number and Dirichlet Random Vector Generating Functions |
---|---|
Description: | Contains functions to generate random numbers from the beta distribution and random vectors from the Dirichlet distribution. |
Authors: | Ching-Wei Cheng [aut, cre], Ying-Chao Hung [aut], Narayanaswamy Balakrishnan [aut] |
Maintainer: | Ching-Wei Cheng <[email protected]> |
License: | GPL-2 |
Version: | 1.0.1 |
Built: | 2025-03-05 03:15:27 UTC |
Source: | https://github.com/cran/rBeta2009 |
Random generation for the beta distribution with parameters shape1
and
shape2
.
rbeta(n, shape1, shape2)
rbeta(n, shape1, shape2)
n |
Number of beta random numbers to generate. If |
shape1 , shape2
|
Positive shape parameters. |
The beta distribution with parameters shape1
and
shape2
has density
for and
.
The mean is and the variance is
.
rbeta
basically utilizes the following guideline primarily proposed by Hung
et al. (2009) for generating beta random numbers.
When shape1
shape2
, the B00 algorithm
(Sakasegawa, 1983) is used;
When shape1
shape2
or shape1
shape2
,
the B01 algorithm (Sakasegawa, 1983) is used;
When shape1
shape1
, the B4PE algorithm
(Schmeiser and Babu, 1980) is used if one papameter is close to 1 and the other is large
(say
); otherwise, the BPRS algorithm (Zechner and Stadlober, 1993) is used.
rbeta
generates beta random numbers.
Ching-Wei Cheng <[email protected]>,
Ying-Chao Hung <[email protected]>,
Narayanaswamy Balakrishnan <[email protected]>
rbeta
uses a C translation of
Y. C. Hung and N. Balakrishnan and Y. T. Lin (2009), Evaluation of beta generation algorithms, Communications in Statistics - Simulation and Computation, 38:750–770.
Y. C. Hung and N. Balakrishnan and Y. T. Lin (2009), Evaluation of beta generation algorithms, Communications in Statistics - Simulation and Computation, 38, 750–770.
H. Sakasegawa (1983), Stratified rejection and squeeze method for generating beta random numbers, Annals of the Institute Statistical Mathematics, 35, 291–302.
B.W. Schmeiser and A.J.G. Babu (1980), Beta variate generation via exponential majorizing functions, Operations Research, 28, 917–926.
H. Zechner and E. Stadlober (1993), Generating beta variates via patchwork rejection, Computing, 50, 1–18.
rbeta
in package stats.
library(rBeta2009) rbeta(10, 0.7, 1.5)
library(rBeta2009) rbeta(10, 0.7, 1.5)
The function to generate random vectors from the Dirichlet distribution.
rdirichlet(n, shape)
rdirichlet(n, shape)
n |
Number of Dirichlet random vectors to generate. If |
shape |
Vector with |
The Dirichlet distribution is the multidimensional generalization of the beta distribution.
A -variate Dirichlet random vector
has
the joint probability density function
where for all
,
, and
are positive shape
parameters.
rdirichlet
generates the Dirichlet random vector by utilizing the transformation
method based on beta variates and three guidelines introduced by Hung et al. (2011).
The three guidelines include: how to choose the fastest beta generation algorithm, how to
best re-order the shape parameters, and how to reduce the amount of arithmetic operations.
rdirichlet()
returns a matrix with n
rows, each containing a single Dirichlet
random vector.
Ching-Wei Cheng <[email protected]>,
Ying-Chao Hung <[email protected]>,
Narayanaswamy Balakrishnan <[email protected]>
rdirichlet
uses a C translation of
Y. C. Hung and N. Balakrishnan and C. W. Cheng (2011), Evaluation of algorithms for generating Dirichlet random vectors, Journal of Statistical Computation and Simulation, 81, 445–459.
Y. C. Hung and N. Balakrishnan and C. W. Cheng (2011), Evaluation of algorithms for generating Dirichlet random vectors, Journal of Statistical Computation and Simulation, 81, 445–459.
rdirichlet
in package MCMCpack.rdirichlet
in package gtools.
library(rBeta2009) rdirichlet(10, c(1.5, 0.7, 5.2, 3.4))
library(rBeta2009) rdirichlet(10, c(1.5, 0.7, 5.2, 3.4))