srou.new {Runuran}R Documentation

UNU.RAN generator based on Simple Ratio-Of-Uniforms Method (SROU)

Description

UNU.RAN random variate generator for continuous distributions with given probability density function (PDF). It is based on the Simple Ratio-Of-Uniforms Method (‘SROU’).

[Universal] – Rejection Method.

Usage

srou.new(pdf, lb, ub, mode, area, islog=FALSE, r=1, ...)

Arguments

pdf probability density function. (R function)
lb lower bound of domain; use -Inf if unbounded from left. (numeric)
ub upper bound of domain; use Inf if unbounded from right. (numeric)
mode location of the mode. (numeric)
area area below pdf. (numeric)
islog whether pdf is given as log-density (the dpdf must then be the derivative of the log-density). (boolean)
r adjust algorithm to heavy-tailed distribution. (numeric)
... (optional) arguments for pdf

Details

This function creates a unuran object based on ‘SROU’ (Simple Ratio-Of-Uniforms Method). 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). The (exact) location of the mode and the area below the pdf are essential. Moreover, the given function must be T_c-concave for c = -r/(r+1); this includes all log-concave distributions).

The acceptance probability decreases with increasing parameter r. Thus it should be as small as possible. On the other hand it must be sufficiently large for heavy tailed distributions. If possible, use the default r=1.

Compared to tdr.new it has much slower marginal generation times but has a faster setup and is numerically more robust. Moreover, It also works for unimodal distributions with tails that are heavier than those of the Cauchy distribution.

Author(s)

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

References

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

See Also

ur, unuran.new, unuran.

Examples

## Create a sample of size 100 for a Gaussian distribution.
pdf <- function (x) { exp(-0.5*x^2) }
gen <- srou.new(pdf=pdf, lb=-Inf, ub=Inf, mode=0, area=2.506628275)
x <- ur(gen,100)

## Create a sample of size 100 for a Gaussian distribution.
## Use 'dnorm'.
gen <- srou.new(pdf=dnorm, lb=-Inf, ub=Inf, mode=0, area=1)
x <- ur(gen,100)


[Package Runuran version 0.9.0 Index]