xerror: Create Table of X-Errors for Numerical Inversion Method

Description Usage Arguments Details Value Note Author(s) See Also Examples

Description

Function for creating a table of x-errors of a numerical inversion method (i.e., it uses an approximate quantile function of the target distribution). Thus the domain of the inverse distribution function is partitioned into intervals for which maxima, minima and some other quantiles of the x-errors are computed.

Currently the function only works for generators for continuous univariate distribution.

Usage

1
2
xerror(n, aqdist, qdist, ..., trunc=NULL, udomain=c(0,1),
       res=1000, kind=c("abs","rel"),tails=FALSE, plot=FALSE)

Arguments

n

sample size for one repetition.

aqdist

approximate inverse distribution function (quantile function) for a continuous univariate distribution.

qdist

(Exact) quatile function of distribution.

...

parameters to be passed to qdist.

trunc

boundaries of truncated domain. (optional)

udomain

domain of investigation for (approximate) quantile function aqdist.

res

resolution (number of intervals).

kind

kind of x-error.

tails

logical. If TRUE, then the tail regions are treated more accurately. However, this doubles the given sample size.

plot

logical. If TRUE, the (range of the) x-errors is plotted.

Details

The absolute x-error of an approximate inverse distribution function (quantile function) G^[-1] for some u in (0,1) is given by

e_x(u) = |F^[-1](u) - G^[-1](u)|

where F^[-1] denotes the (exact) quantile function of the distribution. The relative x-error is then defined as

e_x(u) / |F^[-1](u)|

Computing, plotting and analyzing of such x-errors can be quite time consuming.

e_x(u)

is a very volatile function and requires the computation at a lot of points. For plotting we can condense the information by partitioning (0,1) into intervals of equal length. In each of these the x-error is computed at equidistributed points and some quantiles (see below) are estimated and stored. Thus we save memory and it is much faster to plot and compare x-errors for different methods or distributions.

If trunc is given, then function qdist is rescaled to this given domain. Notice, however, that this has some influence on the accuracy of the results of the “exact” quantile function qdist.

Using argument udomain it is possible to restrict the domain of the given (approximate) quantile function aqdist, i.e., of its argument u.

When tails=TRUE we use additional n points for the first and last interval (which correspond to the tail regions of the distribution).

Value

An object of class "rvgt.ierror", see uerror for details.

Note

It should be noted that xerror computes the difference between the approximate inversion function aqdist(u) and the given ‘exact’ quantile function qdist. Thus one needs a quantile function qdist that is numerically (much) more accurate than aqdist.

The random variate generator rdist can alternatively be a generator object form the Runuran package.

Author(s)

Josef Leydold josef.leydold@wu.ac.at

See Also

See plot.rvgt.ierror for the syntax of the plotting method. See uerror for computing u-errors.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
## Create a table of absolute x-errors for spline interpolation of
## the inverse CDF of the standard normal distribution.
aq <- splinefun(x=pnorm((-100:100)*0.05), y=(-100:100)*0.05,
                method="monoH.FC")
## Use a sample of size of 10^5 random variates.
xerr <- xerror(n=1e5, aqdist=aq, qdist=qnorm, kind="abs")

## Plot x-errors
plot(xerr)


## Same for the relative error.
## But this time we use a resolution of 500, and
## we immediately plot the error.
xerr <- xerror(n=1e5, aqdist=aq, qdist=qnorm,
               res=500, kind="rel", plot=TRUE)


## An inverse CDF for a truncated normal distribution
aqtn <- splinefun(x=(pnorm((0:100)*0.015) - pnorm(0))/(pnorm(1.5)-pnorm(0)),
                  y=(0:100)*0.015, method="monoH.FC")
xerrtn <- xerror(n=1e5, aqdist=aqtn, qdist=qnorm, trunc=c(0,1.5),
                 plot=TRUE)

rvgtest documentation built on May 1, 2019, 6:35 p.m.