Learn R Programming

Runuran (version 0.21.0)

up: Distribution function for "unuran" object

Description

Evaluates the (approximate) cumulative distribution function (CDF) of a "unuran" object for a continuous or discrete distribution.

Usage

up(obj, x)

Arguments

obj
one of
  • a distribution object of class"unuran.cont"that contains the CDF, or
  • a distribution object of class"unuran.discr"that contains the CDF, or
  • a generator object (class"unuran") that
x
vector of x values. (numeric)

Details

The routine evaluates the cumulative distribution function of a distribution stored in a UNU.RAN distribution object or UNU.RAN generator object.

For the computation of the CDF the following alternatives are tried (in the given order):

  1. The CDF is available in objectobj: the function is evaluated and the result is returned.Important:In this case routineupjust evaluates the CDF but ignores the boundaries of the domain of the distribution, i.e., it does not return0and1, resp., outside the domain unless the implementation of the CDF handles this case correctly. This behavior is in particular important whenRunuranbuilt-in distributions are truncated by explicitly setting the domain boundaries.
  2. Objectobjis a generator object that implements methodPINV: In this case an approximate value for the CDF is returned. The approximation error is about one tenth of the requesteduresolutionfor methodPINV.
  3. Neither the CDF nor its approximation is available in objectobj:NAis returned and a warning is thrown.

References

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

See Also

unuran.cont, unuran.discr, unuran, pinv.new.

Examples

Run this code
## Create an UNU.RAN distribution object (for standard Gaussian)
## and evaluate distribution function for some points
distr <- udnorm()
up(distr, 1.5)
up(distr, -3:3)

## Create an UNU.RAN generator object (for standard Gaussian)
## and evaluate distribution function of underyling distribution
unr <- tdrd.new(udnorm())
up(unr, 1.5)
up(unr, -3:3)

## Create an UNU.RAN generator object that does not contain
## the CDF but implements method PINV.
unr <- pinv.new(pdf=function(x){exp(-x)}, lb=0,ub=Inf)
up(unr, 0:5)

Run the code above in your browser using DataLab