Functions to check performance of distribution and quantile functions. Applying the distribution function followed by the quantile function to a set of numbers should reproduce the original set of numbers. Likewise applying the quantile function followed by the distribution function to numbers in the range (0,1) should produce the original numbers.
densFn: Character. The root name of the distribution to be tested.
qs: Numeric. Set of quantiles to which quantile function then distribution function will be applied. See Details .
n: Numeric. Number of values to be sampled from the distribution. See Details .
x: Numeric. Values at which the distribution function is to be evaluated. If NULL values are drawn at random from the distribution.
intTol: Value of rel.tol and hence abs.tol in calls to integrate. See integrate.
uniTol: Value of tol in calls to uniroot. See uniroot.
method: Character. If "spline" quantiles are found from a spline approximation to the distribution function. If "integrate", the distribution function used is always obtained by integration.
...: Additional arguments to allow specification of the parameters of the distribution.
Details
inversionTestpq takes a sample from the specified distribution of size n then applies the distribution function, followed by the quantile function. inversionTestqp applies the quantile function, followed by the distribution function to the set of quantiles specified by qs.
In both cases the starting and ending values should be the same.
These tests are used in base R to check the standard distribution functions. The code may be found in the file d-p-q-r.tests.R in the tests directory.
Returns
inversionTestpq returns a list with components:
qpx: Numeric. The result of applying the distribution function (p function) then the quantile function (q function) to the randomly generated set of x values.
x: Numeric. The set of x values generated by the r
function.
diffs: Numeric. The differences qpx minus x.
n: Numeric. Number of values sampled from the distribution.
inversionTestqp returns a list with components:
pqqs: Numeric. The result of applying the quantile function (q function) then the distribution function (p function) to the quantiles qs.