urbeta {Runuran}R Documentation

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.

Details

The Beta distribution with parameters shape1 =a= a and shape2 =b= b has density

f(x)=Γ(a+b)Γ(a)Γ(b)xa(1x)b f(x) = \frac{\Gamma(a+b)}{\Gamma(a)\Gamma(b)}{x}^{a} {(1-x)}^{b}

for a>0a > 0, b>0b > 0 and 0x10 \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).

Note

This function is wrapper for the UNU.RAN class in R. Compared to rbeta, urbeta is faster, especially for larger sample sizes. However, in opposition to rbeta vector arguments are ignored, i.e. only the first entry is used.

Author(s)

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

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

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

[Package Runuran version 0.38 Index]