This function implements a test of the random number generator and
distribution function based on an inequality due to Massart (1990).
Usage
distIneqMassart(densFn = "norm", n = 10000, probBound = 0.001, ...)
Arguments
densFn
Character. The root name of the distribution to be tested.
n
Numeric. The size of the sample to be used.
probBound
Numeric. The value of the bound on the right hand side of
the Massart inequality. See Details.
...
Additional arguments to allow specification of the
parameters of the distribution.
Details
Massart (1990) gave a version of the Dvoretsky-Kiefer-Wolfowitz
inequality with the best possible constant:
P(sup_x|F_n(x)-F(x)|> t) <= 2exp(-2nt^2)
where F_n is the empirical distribution function for
a sample of n independent and identically distributed random
variables with distribution function F. This inequality is true
for all distribution functions, for all n and t.
This test is used in base R to check the standard distribution
functions. The code may be found in the file p-r-random.tests.R
in the tests directory.
Value
sup
Numeric. The supremum of the absolute difference between
the empirical distribution and the true distribution function.
probBound
Numeric. The value of the bound on the right hand side of
the Massart inequality.
t
Numeric. The lower bound which the supremum of the absolute
difference between the empirical distribution and the true
distribution function must exceed.
pVal
Numeric. The probability that the absolute difference
between the empirical distribution and the true distribution function
exceeds t.
check
Logical. Indicates whether the inequality is satisfied
or not.
Massart P. (1990) The tight constant in the Dvoretsky-Kiefer-Wolfovitz
inequality. Ann. Probab., 18, 1269–1283.
Examples
## Normal distribution is the default
distIneqMassart()
## Specify parameter values
distIneqMassart(mean = 1, sd = 2)
## Gamma distribution has no default value for shape
distIneqMassart("gamma", shape = 1)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(DistributionUtils)
Loading required package: RUnit
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/DistributionUtils/distIneqMassart.Rd_%03d_medium.png", width=480, height=480)
> ### Name: distIneqMassart
> ### Title: Massart Inequality for Distributions
> ### Aliases: distIneqMassart
> ### Keywords: distribution univariate
>
> ### ** Examples
>
> ## Normal distribution is the default
> distIneqMassart()
$sup
[1] 0.012
$probBound
[1] 0.001
$t
[1] 0.01949475
$pVal
[1] 0.1295
$check
[1] TRUE
> ## Specify parameter values
> distIneqMassart(mean = 1, sd = 2)
$sup
[1] 0.0069
$probBound
[1] 0.001
$t
[1] 0.01949475
$pVal
[1] 0.7788
$check
[1] TRUE
> ## Gamma distribution has no default value for shape
> distIneqMassart("gamma", shape = 1)
$sup
[1] 0.008
$probBound
[1] 0.001
$t
[1] 0.01949475
$pVal
[1] 0.5549
$check
[1] TRUE
>
>
>
>
>
> dev.off()
null device
1
>