This class contains methods used to format results of GOF test statistics, or to apply a series of tests simultaneously and format the results.
More...
|
static final int | GNUPLOT = 0 |
| Data file format used for plotting functions with Gnuplot.
|
|
static final int | MATHEMATICA = 1 |
| Data file format used for creating graphics with Mathematica.
|
|
static int | graphSoft = GNUPLOT |
| Environment variable that selects the type of software to be used for plotting the graphs of functions. More...
|
|
static String | drawCdf (ContinuousDistribution dist, double a, double b, int m, String desc) |
| Formats data to plot the graph of the distribution function \(F\) over the interval \([a,b]\), and returns the result as a String. More...
|
|
static String | drawDensity (ContinuousDistribution dist, double a, double b, int m, String desc) |
| Formats data to plot the graph of the density \(f(x)\) over the interval \([a,b]\), and returns the result as a String. More...
|
|
static String | graphDistUnif (DoubleArrayList data, String desc) |
| Formats data to plot the empirical distribution of \(U_{(1)},…,U_{(N)}\), which are assumed to be in data[0...N-1] , and to compare it with the uniform distribution. More...
|
|
|
static double | EPSILONP = 1.0E-15 |
| Environment variable used in formatp0 to determine which \(p\)-values are too close to 0 or 1 to be printed explicitly. More...
|
|
static double | SUSPECTP = 0.01 |
| Environment variable used in formatp1 to determine which \(p\)-values should be marked as suspect when printing test results. More...
|
|
static String | formatp0 (double p) |
| Returns the \(p\)-value \(p\) of a test, in the format "@f$1-p@f$" if \(p\) is close to 1, and \(p\) otherwise. More...
|
|
static String | formatp1 (double p) |
| Returns the string "<tt>p-value of test : </tt>", then calls formatp0 to print \(p\), and adds the marker "<tt>****</tt>" if \(p\) is considered suspect (uses the environment variable SUSPECTP for this). More...
|
|
static String | formatp2 (double x, double p) |
| Returns x on a single line, then go to the next line and calls formatp1. More...
|
|
static String | formatp3 (String testName, double x, double p) |
| Formats the test statistic x for a test named testName with \(p\)-value p . More...
|
|
static String | formatChi2 (int k, int d, double chi2) |
| Computes the \(p\)-value of the chi-square statistic chi2 for a test with k intervals. More...
|
|
static String | formatKS (int n, double dp, double dm, double d) |
| Computes the \(p\)-values of the three Kolmogorov-Smirnov statistics \(D_N^+\), \(D_N^-\), and \(D_N\), whose values are in dp, dm, d , respectively, assuming a sample of size n . More...
|
|
static String | formatKS (DoubleArrayList data, ContinuousDistribution dist) |
| Computes the KS test statistics to compare the empirical distribution of the observations in data with the theoretical distribution dist and formats the results. More...
|
|
static String | formatKSJumpOne (int n, double a, double dp) |
| Similar to formatKS(int,double,double,double), but for the KS statistic \(D_N^+(a)\) defined in ( KSPlusJumpOne ). More...
|
|
static String | formatKSJumpOne (DoubleArrayList data, ContinuousDistribution dist, double a) |
| Similar to formatKS(DoubleArrayList,ContinuousDistribution), but for \(D_N^+(a)\) defined in ( KSPlusJumpOne ). More...
|
|
|
Higher-level tools for applying several EDF goodness-of-fit tests simultaneously are offered here.
The environment variable activeTests specifies which tests in this list are to be performed when asking for several simultaneous tests via the functions activeTests , formatActiveTests , etc.
|
static final int | KSP = 0 |
| Kolmogorov-Smirnov+ test.
|
|
static final int | KSM = 1 |
| Kolmogorov-Smirnov \(-\) test.
|
|
static final int | KS = 2 |
| Kolmogorov-Smirnov test.
|
|
static final int | AD = 3 |
| Anderson-Darling test.
|
|
static final int | CM = 4 |
| Cramér-von Mises test.
|
|
static final int | WG = 5 |
| Watson G test.
|
|
static final int | WU = 6 |
| Watson U test.
|
|
static final int | MEAN = 7 |
| Mean.
|
|
static final int | COR = 8 |
| Correlation.
|
|
static final int | NTESTTYPES = 9 |
| Total number of test types.
|
|
static final String [] | TESTNAMES |
| Name of each testType test. More...
|
|
static boolean [] | activeTests = null |
| The set of EDF tests that are to be performed when calling the methods activeTests, formatActiveTests, etc. More...
|
|
static void | tests (DoubleArrayList sortedData, double[] sVal) |
| Computes all EDF test statistics enumerated above (except COR ) to compare the empirical distribution of \(U_{(0)},…,U_{(N-1)}\) with the uniform distribution, assuming that these sorted observations are in sortedData . More...
|
|
static void | tests (DoubleArrayList data, ContinuousDistribution dist, double[] sVal) |
| The observations \(V\) are in data , not necessarily sorted, and their empirical distribution is compared with the continuous distribution dist . More...
|
|
static void | activeTests (DoubleArrayList sortedData, double[] sVal, double[] pVal) |
| Computes the EDF test statistics by calling #tests(DoubleArrayList,double[]), then computes the \(p\)-values of those that currently belong to activeTests , and return these quantities in sVal and pVal , respectively. More...
|
|
static void | activeTests (DoubleArrayList data, ContinuousDistribution dist, double[] sVal, double[] pVal) |
| The observations are in data , not necessarily sorted, and we want to compare their empirical distribution with the distribution dist . More...
|
|
static String | formatActiveTests (int n, double[] sVal, double[] pVal) |
| Gets the \(p\)-values of the active EDF test statistics, which are in activeTests . More...
|
|
static String | iterSpacingsTests (DoubleArrayList sortedData, int k, boolean printval, boolean graph, PrintWriter f) |
| Repeats the following k times: Applies the GofStat.iterateSpacings transformation to the \(U_{(0)},…,U_{(N-1)}\), assuming that these observations are in sortedData , then computes the EDF test statistics and calls #activeTests(DoubleArrayList,double[],double[]) after each transformation. More...
|
|
static String | iterPowRatioTests (DoubleArrayList sortedData, int k, boolean printval, boolean graph, PrintWriter f) |
| Similar to iterSpacingsTests, but with the GofStat.powerRatios transformation. More...
|
|
| [static initializer] |
|
This class contains methods used to format results of GOF test statistics, or to apply a series of tests simultaneously and format the results.
It is in fact a translation from C to Java of a set of functions that were specially written for the implementation of TestU01, a software package for testing uniform random number generators [133] .
Strictly speaking, applying several tests simultaneously makes the \(p\)-values "invalid" in the sense that the probability of having at least one \(p\)-value less than 0.01, say, is larger than 0.01. One must therefore be careful with the interpretation of these \(p\)-values (one could use, e.g., the Bonferroni inequality [118] ). Applying simultaneous tests is convenient in some situations, such as in screening experiments for detecting statistical deficiencies in random number generators. In that context, rejection of the null hypothesis typically occurs with extremely small \(p\)-values (e.g., less than \(10^{-15}\)), and the interpretation is quite obvious in this case.
The class also provides tools to plot an empirical or theoretical distribution function, by creating a data file that contains a graphic plot in a format compatible with the software specified by the environment variable graphSoft. NOTE: see also the more recent package umontreal.ssj.charts.
Note: This class uses the Colt library.
static void activeTests |
( |
DoubleArrayList |
sortedData, |
|
|
double [] |
sVal, |
|
|
double [] |
pVal |
|
) |
| |
|
static |
Computes the EDF test statistics by calling #tests(DoubleArrayList,double[]), then computes the \(p\)-values of those that currently belong to activeTests
, and return these quantities in sVal
and pVal
, respectively.
Assumes that \(U_{(0)},…,U_{(N-1)}\) are in sortedData
and that we want to compare their empirical distribution with the uniform distribution. If \(N = 1\), only puts \(1 - {}\)sortedData.get (0)
in sVal[KSP], pVal[KSP]
, and pVal[MEAN]
.
- Parameters
-
sortedData | array of sorted observations |
sVal | array that will be filled with the results of the tests |
pVal | array that will be filled with the \(p\)-values |
Formats data to plot the graph of the distribution function \(F\) over the interval \([a,b]\), and returns the result as a String.
The method dist.cdf(x)
returns the value of \(F\) at \(x\). The String desc
gives a short caption for the graphic plot. The method computes the \(m+1\) points \((x_i, F (x_i))\), where \(x_i = a + i (b-a)/m\) for \(i=0,1,…,m\), and formats these points into a String
in a format suitable for the software specified by graphSoft. NOTE: see also the more recent class umontreal.ssj.charts.ContinuousDistChart.
- Parameters
-
dist | continuous distribution function to plot |
a | lower bound of the interval to plot |
b | upper bound of the interval to plot |
m | number of points in the plot minus one |
desc | short caption describing the plot |
- Returns
- a string representation of the plot data
Formats data to plot the graph of the density \(f(x)\) over the interval \([a,b]\), and returns the result as a String.
The method dist.density(x)
returns the value of \(f(x)\) at \(x\). The String desc
gives a short caption for the graphic plot. The method computes the \(m+1\) points \((x_i, f(x_i))\), where \(x_i = a + i (b-a)/m\) for \(i=0,1,…,m\), and formats these points into a String
in a format suitable for the software specified by graphSoft. NOTE: see also the more recent class umontreal.ssj.charts.ContinuousDistChart.
- Parameters
-
dist | continuous density function to plot |
a | lower bound of the interval to plot |
b | upper bound of the interval to plot |
m | number of points in the plot minus one |
desc | short caption describing the plot |
- Returns
- a string representation of the plot data
static String iterSpacingsTests |
( |
DoubleArrayList |
sortedData, |
|
|
int |
k, |
|
|
boolean |
printval, |
|
|
boolean |
graph, |
|
|
PrintWriter |
f |
|
) |
| |
|
static |
Repeats the following k
times: Applies the GofStat.iterateSpacings transformation to the \(U_{(0)},…,U_{(N-1)}\), assuming that these observations are in sortedData
, then computes the EDF test statistics and calls #activeTests(DoubleArrayList,double[],double[]) after each transformation.
The function returns the original array sortedData
(the transformations are applied on a copy of sortedData
). If printval = true
, stores all the values into the returned String after each iteration. If graph = true
, calls graphDistUnif after each iteration to print to stream f
the data for plotting the distribution function of the \(U_i\).
- Parameters
-
sortedData | array containing the sorted observations |
k | number of times the tests are applied |
printval | if true , stores all the values of the observations at each iteration |
graph | if true , the distribution of the \(U_i\) will be plotted after each iteration |
f | stream where the plots are written to |
- Returns
- a string representation of the test results
static void tests |
( |
DoubleArrayList |
sortedData, |
|
|
double [] |
sVal |
|
) |
| |
|
static |
Computes all EDF test statistics enumerated above (except COR
) to compare the empirical distribution of \(U_{(0)},…,U_{(N-1)}\) with the uniform distribution, assuming that these sorted observations are in sortedData
.
If \(N > 1\), returns sVal
with the values of the KS statistics \(D_N^+\), \(D_N^-\) and \(D_N\), of the Cramér-von Mises statistic \(W_N^2\), Watson’s \(G_N\) and \(U_N^2\), Anderson-Darling’s \(A_N^2\), and the average of the \(U_i\)’s, respectively. If \(N = 1\), only puts \(1 - {}\)sortedData.get (0)
in sVal[KSP]
. Calling this method is more efficient than computing these statistics separately by calling the corresponding methods in GofStat.
- Parameters
-
sortedData | array of sorted observations |
sVal | array that will be filled with the results of the tests |
boolean [] activeTests = null |
|
static |
The set of EDF tests that are to be performed when calling the methods activeTests, formatActiveTests, etc.
By default, this set contains KSP
, KSM
, and AD
. Note: MEAN
and COR
are always excluded from this set of active tests. The valid indices for this array are KSP, KSM, KS, AD, CM, WG, WU, MEAN, and COR.