Random generation for the beta distribution with parameters `shape1`

and
`shape2`

.

1 | ```
rbeta(n, shape1, shape2)
``` |

`n` |
Number of beta random numbers to generate. If |

`shape1, shape2` |
Positive shape parameters. |

The beta distribution with parameters `shape1`

* = a* and `shape2`

* = b*
has density

*
Γ(a+b)/(Γ(a)Γ(b)) x^(a-1)(1-x)^(b-1)*

for *a > 0, b > 0* and *0 ≤ x ≤ 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.

When

*max(*`shape1`

*,*`shape2`

*) < 1*, the B00 algorithm (Sakasegawa, 1983) is used;When

`shape1`

*< 1 <*`shape2`

or`shape1`

*> 1 >*`shape2`

, the B01 algorithm (Sakasegawa, 1983) is used;When

*min(*`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`

generates beta random numbers.

Ching-Wei Cheng <aks43725@gmail.com>,

Ying-Chao Hung <hungy@nccu.edu.tw>,

Narayanaswamy Balakrishnan <bala@univmail.cis.mcmaster.ca>

`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.

1 2 |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.