Learn R Programming

Runuran (version 0.10.1)

itdr.new: UNU.RAN generator based on Inverse Transformed Density Rejection (ITDR)

Description

UNU.RAN random variate generator for continuous distributions with given probability density function (PDF). It is based on the Inverse Transformed Density Rejection method (ITDR).

[Universal] -- Rejection Method.

Usage

itdr.new(pdf, dpdf, lb, ub, pole, islog=FALSE, ...)

Arguments

pdf
probability density function. (Rfunction)
dpdf
derivative of pdf. (Rfunction)
pole
pole of distribution. (numeric)
lb
lower bound of domain; use -Inf if unbounded from left. (numeric)
ub
upper bound of domain; use Inf if unbounded from right. (numeric)
islog
whether pdf is given as log-density (the dpdf must then be the derivative of the log-density). (boolean)
...
(optional) arguments for pdf

Details

This function creates a unuran object based on ITDR (Inverse Transformed Density Rejection). It can be used to draw samples of a continuous random variate with given probability density function using ur. The density must be provided by a function pdf which must return non-negative numbers and which need not be normalized (i.e., it can be any multiple of a density function). Moreover, it must be monotone on its domain. The algorithm is especially designed for distributions with unbounded densities. Thus the algorithm need the position of the pole.

The derivative dpdf is essential. (Numerical derivation does not work as it results in serious round-off errors.) The setup time of this method depends on the given PDF, whereas its marginal generation times are almost independent of the target distribution.

References

W. H"ormann, J. Leydold, and G. Derflinger (2007): Inverse transformed density rejection for unbounded monotone densities. ACM Trans. Model. Comput. Simul. 17(4), Article 18, 16 pages. DOI = 10.1145/1276927.1276931

See Also

ur, unuran.new, unuran.

Examples

Run this code
## Create a sample of size 100 for a Gamma(-0.5) distribution
pdf <- function (x) { x^(-0.5)*exp(-x) }
dpdf <- function (x) { (-x^(-0.5) - 0.5*x^(-1.5))*exp(-x) }
gen <- itdr.new(pdf=pdf, dpdf=dpdf, lb=0, ub=Inf, pole=0)
x <- ur(gen,100)

Run the code above in your browser using DataLab