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

Function for creating a table of u-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 u-errors are computed.

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

1 2 |

`n` |
sample size for one repetition. |

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

`pdist` |
cumulative distribution function for distribution. |

`... ` |
parameters to be passed to |

`trunc` |
boundaries of truncated domain. (optional) |

`udomain` |
domain of investigation for (approximate) quantile
function |

`res` |
resolution (number of intervals). |

`tails` |
logical. If |

`plot` |
logical. If |

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

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

where *F* denotes the (exact) cumulative distribution.
It is a convenient measure for approximation errors in non-uniform
random variate generators bases on numerical inversion, see the
reference below for our arguments.

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

*e_u(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 u-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 u-errors for different methods or distributions.

If `trunc`

is given, then function `pdist`

is rescaled to
this given domain. Notice, however, that this has some influence on
the accuracy of the results of the distribution function `pdist`

.

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).

An object of class `"rvgt.ierror"`

which is a list with components:

`n` |
sample size. |

`res` |
resolution (number of intervals). |

`kind` |
kind of error (string). |

`udomain` |
domain for u. |

`min` |
an array of minimum u-errors (of length |

`lqr` |
an array of lower quartile of u-errors (of length |

`med` |
an array of median u-errors (of length |

`uqr` |
an array of upper quartile of u-errors (of length |

`max` |
an array of maximum u-errors (of length |

`mad` |
an array of mean absolute deviations (of length |

`mse` |
an array of mean squared errors (of length |

It should be noted that `uerror`

computes the numerical
error of the *composed* function `pdist(aqdist(u))`

.
Thus one needs a distribution function `pdist`

that is
numerically (much) more accurate than `aqdist`

.

The random variate generator `rdist`

can alternatively be a
generator object form the
Runuran package.

Josef Leydold [email protected]

G. Derflinger, W. H\"ormann, and J. Leydold (2009): ACM Trans. Model. Comput. Simul., to appear.

See `plot.rvgt.ierror`

for the syntax of the plotting
method. See `xerror`

for computing x-errors.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | ```
## Create a table of u-errors for spline interpolation of
## the inverse CDF of the standard normal distribution.
aqn <- 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.
uerrn <- uerror(n=1e5, aqdist=aqn, pdist=pnorm)
## Plot u-errors
plot(uerrn)
## Investigate tails more accurately, and use
## a resolution of 1000 intervals.
uerrn <- uerror(n=1e5, aqdist=aqn, pdist=pnorm, res=1000, tails=TRUE)
## Same for a gamma distribution.
## But this time we immediately plot the error.
aqg <- splinefun(x=pgamma((0:500)*0.1,shape=5),
y=(0:500)*0.1, method="monoH.FC")
uerrg <- uerror(n=1e5, aqdist=aqg, pdist=pgamma, shape=5,
plot=TRUE)
## Compute u-error for a subdomain of a beta distribution
aqb <- splinefun(x=pbeta((0:100)*0.01,shape1=2,shape2=5),
y=(0:100)*0.01, method="monoH.FC")
uerrb <- uerror(n=1e5, aqdist=aqb, pdist=pbeta, shape1=2, shape2=5,
udomain=c(0.6,0.65), plot=TRUE)
## Show all u-errors in one plot
plot.rvgt.ierror(list(uerrn,uerrg,uerrb))
## 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")
uerrtn <- uerror(n=1e5, aqdist=aqtn, pdist=pnorm, trunc=c(0,1.5),
plot=TRUE)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.