# itdr.new: UNU.RAN generator based on Inverse Transformed Density... In Runuran: R Interface to the 'UNU.RAN' Random Variate Generators

## 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

 ```1 2``` ```itdr.new(pdf, dpdf, lb, ub, pole, islog=FALSE, ...) itdrd.new(distr) ```

## Arguments

 `pdf` probability density function. (R function) `dpdf` derivative of `pdf`. (R function) `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`. `distr` distribution object. (S4 object of class `"unuran.cont"`)

## 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 `pdf` must be positive but need not be normalized (i.e., it can be any multiple of a density function). The algorithm is especially designed for distributions with unbounded densities. Thus the algorithm needs the position of the `pole`. Moreover, the given function must be monotone on its domain.

The derivative `dpdf` is essential. (Numerical derivation does not work as it results in serious round-off errors.)

Alternatively, one can use function `itdrd.new` where the object `distr` of class `"unuran.cont"` must contain all required information about the distribution.

The setup time of this method depends on the given PDF, whereas its marginal generation times are almost independent of the target distribution.

## Value

An object of class `"unuran"`.

## Author(s)

Josef Leydold and Wolfgang H\"ormann [email protected].

## 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

`ur`, `unuran.cont`, `unuran.new`, `unuran`.
 ``` 1 2 3 4 5 6 7 8 9 10``` ```## 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) ## Alternative approach distr <- udgamma(shape=0.5) gen <- itdrd.new(distr) x <- ur(gen,100) ```