Learn R Programming

Runuran (version 0.5)

unuran.new: Create a UNU.RAN object

Description

Create a new UNU.RAN object in package Runuran that can be used for sampling from the specified distribution. The function unuran.sample can then be used to draw a random sample.

Usage

unuran.new(distr,method="auto")

Arguments

distr
a string or an S4 class describing the distribution.
method
a string describing the random variate generation method.

Details

The UNU.RAN package works in the following way: [object Object],[object Object]

References

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

See Also

runif and .Random.seed about random number generation, unuran for the UNU.RAN class, unuran.sample, urtdr, urdgt and urdau.

For distribution objects see unuran.cont, unuran.discr, and unuran.cmv.

Examples

Run this code
## Make histograms for samples of size 10000 for some non-standard distributions

unr <- new("unuran", "cont; pdf='log(x)*(x<1.3098)+(x>1.3098)*exp(-x)'; domain = (1, Inf)", "TDR");
x <- unuran.sample(unr,10000);
hist(x)

unr <- new("unuran", "distr=cont; pdf='1/x^3'; domain = (0.5, Inf)", "TDR");
x <- unuran.sample(unr,10000);
hist(x)

unr <- new("unuran", "distr=discr; pmf='1/(2+x)^3'; domain = (1, Inf);pmfsum=0.05","DARI");
x <- unuran.sample(unr,10000);
hist(x)

Run the code above in your browser using DataLab