Learn R Programming

Runuran (version 0.40)

Runuran.distributions: UNU.RAN distribution objects

Description

Create objects for particular distributions suitable for using with generation methods from the UNU.RAN library.

Arguments

Author

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

Details

Runuran provides an interface to the UNU.RAN library for universal non-uniform random number generators. This is a very flexible and powerful collection of sampling routines, where the user first has to specify the target distribution and then has to choose an appropriate sampling method.

Creating an object for a particular distribution can be a bit tedious especially if the target distribution has a more complex density function. Thus we have compiled a set of functions that provides ready-to-use distribution objects. Moreover, using these object often results in faster setup time than objects created with pure R code.

These functions share a similar syntax and naming scheme (only ud is prefixed) with analogous R built-in functions that provide density, distribution function and quantile:

ud...(distribution parameters, lb , ub)

Currently generators for the following distributions are implemented.

Continuous Univariate Distributions (26):

FunctionDistribution
udbeta...Beta
udcauchy...Cauchy
udchi...Chi
udchisq...Chi-squared
udexp...Exponential
udf...F
udfrechet...Frechet (Extreme value type II)
udgamma...Gamma
udghyp...Generalized Hyperbolic
udgig...Generalized Inverse Gaussian
udgumbel...Gumbel (Extreme value type I)
udhyperbolic...Hyperbolic
udig...Inverse Gaussian (Wald)
udlaplace...Laplace (double exponential)
udlnorm...Log Normal
udlogis...Logistic
udlomax...Lomax (Pareto of second kind)
udmeixner...Meixner
udnorm...Normal (Gaussian)
udpareto...Pareto (of first kind)
udpowerexp...Powerexponential (Subbotin)
udrayleigh...Rayleigh
udslash...Slash
udt...t (Student)
udvg...Variance Gamma
udweibull...Weibull (Extreme value type III)

Discrete Distributions (6):

FunctionDistribution
udbinom...Binomial
udgeom...Geometric
udhyper...Hypergeometric
udlogarithmic...Logarithmic
udnbinom...Negative Binomial
udpois...Poisson

See Also

Runuran-package.

Examples

Run this code
## Create an object for a gamma distribution with shape parameter 5.
distr <- udgamma(shape=5)
## Create the UNU.RAN generator object. use method PINV (inversion).
gen <- pinvd.new(distr)
## Draw a sample of size 100
x <- ur(gen, 100)
## Compute some quantiles for Monte Carlo methods
x <- uq(gen, (1:9)/10)

## Analogous for half normal distribution
distr <- udnorm(lb=0, ub=Inf)
gen <- pinvd.new(distr)
x <- ur(gen, 100)
x <- uq(gen, (1:9)/10)

## Analogous for a generalized hyperbolic distribution
distr <- udghyp(lambda=-1.0024, alpha=39.6, beta=4.14, delta=0.0118, mu=-0.000158)
gen <- pinvd.new(distr)
x <- ur(gen, 100)
x <- uq(gen, (1:9)/10)

## It is also possible to compute density or distribution functions.
## However, this might not work for all generator objects.
##    Density
x <- ud(gen, 1.2)
##    Cumulative distribution function
x <- up(gen, 1.2)

Run the code above in your browser using DataLab