dgt.new {Runuran}R Documentation

UNU.RAN generator based on table guided discrete inversion (DGT)

Description

UNU.RAN random variate generator for discrete distributions with given probability vector. It applies the Guide-Table Method for discrete inversion (‘DGT’).

[Universal] – Inversion Method.

Usage

dgt.new(pv, from=1)

Arguments

pv vector of non-negative numbers (need not sum to 1). (numeric vector)
from index of first entry in vector. (integer)

Details

This function creates an unuran object based on ‘DGT’ (Discrete Guide-Table method). It can be used to draw samples of a discrete random variate with given probability vector using ur.

The probabilities must be provided by a vector pv which must contain non-negative numbers and need not necessarily sum up to 1.

The method runs fast in constant time, i.e., marginal sampling times do not depend on the length of the given probability vector. Whereas their setup times grow linearly with this length.

Notice that the range of random variates is from:(from+length(pv)-1).

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. See Section 3.1.2 (Indexed Search).

H.C. Chen and Y. Asau (1974): On generating random variates from an empirical distribution. AIIE Trans. 6, pp.163–166.

See Also

ur, unuran.new, unuran.

Examples

## Create a sample of size 100 for a 
## binomial distribution with size=115, prob=0.5
gen <- dgt.new(pv=dbinom(0:115,115,0.5))
x <- ur(gen,100)

[Package Runuran version 0.9.0 Index]