shape1 and
shape2.
rbeta(n, shape1, shape2)length(n) > 1, the length
is taken to be the number required.rbeta generates beta random numbers.
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.shape1$ = a$ and shape2$ = b$
has density
$$\frac{\Gamma(a+b)}{\Gamma(a)\Gamma(b)} x^{a-1} (1-x)^{b-1}$$
for $a > 0, b > 0$ and $0 \le x \le 1$.
The mean is $a/(a+b)$ and the variance is
$ab/((a+b)^2 (a+b+1))$.
rbeta basically utilizes the following guideline primarily proposed by Hung
et al. (2009) for generating beta random numbers.
shape1$, $shape2$) < 1$, the B00 algorithm
(Sakasegawa, 1983) is used;
shape1$ < 1 < $shape2 or shape1$ > 1 > $shape2,
the B01 algorithm (Sakasegawa, 1983) is used;
shape1$, $shape1$) > 1$, the B4PE algorithm
(Schmeiser and Babu, 1980) is used if one papameter is close to 1 and the other is large
(say $> 4$); otherwise, the BPRS algorithm (Zechner and Stadlober, 1993) is used.
rbeta in package stats.
library(rBeta2009)
rbeta(10, 0.7, 1.5)
Run the code above in your browser using DataLab