Create objects for particular distributions suitable for using with generation methods from the UNU.RAN library.
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 code.
These functions share a similar syntax and naming scheme (only ud is prefixed) with analogous built-in functions that provide density, distribution function and quantile:
ud...(distribution parameters, lb , ub)
Currently generators for the following distributions are implemented.
## 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 100x <- ur(gen,100)## Compute some quantiles for Monte Carlo methodsx <- uq(gen,(1:9)/10)## Analogous for half normal distributiondistr <- udnorm(lb=0, ub=Inf)gen <- pinvd.new(distr)x <- ur(gen,100)x <- uq(gen,(1:9)/10)## Analogous for a generalized hyperbolic distributiondistr <- 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.## Densityx <- ud(gen,1.2)## Cumulative distribution functionx <- up(gen,1.2)