Learn R Programming

Runuran (version 0.40)

urbeta: UNU.RAN Beta random variate generator

Description

UNU.RAN random variate generator for the Beta distribution with parameters shape1 and shape2. It also allows sampling from the truncated distribution.

[Special Generator] -- Sampling Function: Beta.

Usage

urbeta(n, shape1, shape2, lb = 0, ub = 1)

Arguments

n

size of required sample.

shape1,shape2

positive shape parameters of the Beta distribution.

lb

lower bound of (truncated) distribution.

ub

upper bound of (truncated) distribution.

Author

Josef Leydold and Wolfgang H\"ormann unuran@statmath.wu.ac.at.

Details

The Beta distribution with parameters shape1 \(= a\) and shape2 \(= b\) has density $$ f(x) = \frac{\Gamma(a+b)}{\Gamma(a)\Gamma(b)}{x}^{a} {(1-x)}^{b} $$ for \(a > 0\), \(b > 0\) and \(0 \le x \le 1\).

The generation algorithm uses fast numerical inversion. The parameters lb and ub can be used to generate variates from the Beta distribution truncated to the interval (lb,ub).

References

W. H\"ormann, J. Leydold, and G. Derflinger (2004): Automatic Nonuniform Random Variate Generation. Springer-Verlag, Berlin Heidelberg

See Also

runif and .Random.seed about random number generation, unuran for the UNU.RAN class, and rbeta for the R built-in generator.

Examples

Run this code
## Create a sample of size 1000
x <- urbeta(n=1000,shape1=2,shape2=5)

Run the code above in your browser using DataLab