urbeta function

UNU.RAN Beta random variate generator

UNU.RAN Beta random variate generator

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.

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)bf(x)=Gamma(a+b)/(Gamma(a)Gamma(b))x(a1)(1x)(b1) f(x) = \frac{\Gamma(a+b)}{\Gamma(a)\Gamma(b)}{x}^{a} {(1-x)}^{b}f(x) = Gamma(a+b)/(Gamma(a)Gamma(b))x^(a-1)(1-x)^(b-1)

for a>0a > 0, b>0b > 0 and 0<=x<=10 <= x <= 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).

See Also

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

References

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

Author(s)

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

Note

This function is wrapper for the UNU.RAN class in . 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.

Examples

## Create a sample of size 1000 x <- urbeta(n=1000,shape1=2,shape2=5)
  • Maintainer: Josef Leydold
  • License: GPL (>= 2)
  • Last published: 2025-04-07