
SSJ V. 2.6. 

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 
java.lang.Object umontreal.iro.lecuyer.gof.GofFormat
public class GofFormat
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.
Strictly speaking, applying several tests simultaneously makes the pvalues ``invalid'' in the sense that the probability of having at least one pvalue less than 0.01, say, is larger than 0.01. One must therefore be careful with the interpretation of these pvalues (one could use, e.g., the Bonferroni inequality). 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 pvalues (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
charts
.
Note: This class uses the Colt library.
Field Summary  

static boolean[] 
activeTests
The set of EDF tests that are to be performed when calling the methods activeTests , formatActiveTests , etc. 
static int 
AD
AndersonDarling test 
static int 
CM
Cramérvon Mises test 
static int 
COR
Correlation 
static double 
EPSILONP
Environment variable used in formatp0 to determine
which pvalues are too close to 0 or 1 to be printed explicitly. 
static int 
GNUPLOT
Data file format used for plotting functions with Gnuplot. 
static int 
graphSoft
Environment variable that selects the type of software to be used for plotting the graphs of functions. 
static int 
KS
KolmogorovSmirnov test 
static int 
KSM
KolmogorovSmirnov test 
static int 
KSP
KolmogorovSmirnov+ test 
static int 
MATHEMATICA
Data file format used for creating graphics with Mathematica. 
static int 
MEAN
Mean 
static int 
NTESTTYPES
Total number of test types 
static double 
SUSPECTP
Environment variable used in formatp1 to determine
which pvalues should be marked as suspect when printing test results. 
static String[] 
TESTNAMES
Name of each testType test. 
static int 
WG
Watson G test 
static int 
WU
Watson U test 
Method Summary  

static void 
activeTests(cern.colt.list.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. 
static void 
activeTests(cern.colt.list.DoubleArrayList sortedData,
double[] sVal,
double[] pVal)
Computes the EDF test statistics by calling tests , then computes the pvalues of those
that currently belong to activeTests,
and return these quantities in sVal and pVal, respectively. 
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 . 
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 . 
static String 
formatActiveTests(int n,
double[] sVal,
double[] pVal)
Gets the pvalues of the active EDF test statistics, which are in activeTests. 
static String 
formatChi2(int k,
int d,
double chi2)
Computes the pvalue of the chisquare statistic chi2 for a test with k intervals. 
static String 
formatKS(cern.colt.list.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. 
static String 
formatKS(int n,
double dp,
double dm,
double d)
Computes the pvalues of the three KolmogorovSmirnov statistics D_{N}^{+}, D_{N}^{}, and D_{N}, whose values are in dp, dm, d, respectively, assuming a sample of size n. 
static String 
formatKSJumpOne(cern.colt.list.DoubleArrayList data,
ContinuousDistribution dist,
double a)
Similar to formatKS ,
but for D_{N}^{+}(a). 
static String 
formatKSJumpOne(int n,
double a,
double dp)
Similar to formatKS ,
but for the KS statistic D_{N}^{+}(a). 
static String 
formatp0(double p)
Returns the pvalue p of a test, in the format ``1  p'' if p is close to 1, and p otherwise. 
static String 
formatp1(double p)
Returns the string ``pvalue of test : '', then calls formatp0 to print p, and adds
the marker ``****'' if p is considered suspect
(uses the environment variable SUSPECTP for this). 
static String 
formatp2(double x,
double p)
Returns x on a single line, then go to the next line and calls formatp1 . 
static String 
formatp3(String testName,
double x,
double p)
Formats the test statistic x for a test named testName with pvalue p. 
static String 
graphDistUnif(cern.colt.list.DoubleArrayList data,
String desc)
Formats data to plot the empirical distribution of U_{(1)},..., U_{(N)}, which are assumed to be in data[0...N1], and to compare it with the uniform distribution. 
static String 
iterPowRatioTests(cern.colt.list.DoubleArrayList sortedData,
int k,
boolean printval,
boolean graph,
PrintWriter f)
Similar to iterSpacingsTests , but with the
GofStat.powerRatios transformation. 
static String 
iterSpacingsTests(cern.colt.list.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_{(N1)}, assuming that these observations are in
sortedData, then computes the EDF test statistics and calls
activeTests after each transformation. 
static void 
tests(cern.colt.list.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. 
static void 
tests(cern.colt.list.DoubleArrayList sortedData,
double[] sVal)
Computes all EDF test statistics to compare the empirical distribution of U_{(0)},..., U_{(N1)} with the uniform distribution, assuming that these sorted observations are in sortedData. 
Methods inherited from class java.lang.Object 

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 
Field Detail 

public static final int GNUPLOT
public static final int MATHEMATICA
public static int graphSoft
graphFunc
and
graphDistUnif
will be in a format suitable
for this selected software.
The default value is GNUPLOT.
To display a graphic in file f using gnuplot, for example,
one can use the command ``plot f with steps, x with lines''
in gnuplot.
graphSoft can take the values GNUPLOT
or MATHEMATICA
.
public static double EPSILONP
formatp0
to determine
which pvalues are too close to 0 or 1 to be printed explicitly.
If EPSILONP
= ε, then any pvalue
less than ε or larger than
1  ε is not written explicitly;
the program simply writes ``eps'' or ``1eps''.
The default value is 10^{15}.
public static double SUSPECTP
formatp1
to determine
which pvalues should be marked as suspect when printing test results.
If SUSPECTP = α, then any pvalue
less than α or larger than
1  α is considered suspect and is
``singled out'' by formatp1.
The default value is 0.01.
public static final int KSP
public static final int KSM
public static final int KS
public static final int AD
public static final int CM
public static final int WG
public static final int WU
public static final int MEAN
public static final int COR
public static final int NTESTTYPES
public static final String[] TESTNAMES
public static boolean[] activeTests
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
.
Method Detail 

public static String drawCdf(ContinuousDistribution dist, double a, double b, int m, String desc)
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
ContinuousDistChart
.
dist
 continuous distribution function to plota
 lower bound of the interval to plotb
 upper bound of the interval to plotm
 number of points in the plot minus onedesc
 short caption describing the plot
public static String drawDensity(ContinuousDistribution dist, double a, double b, int m, String desc)
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
ContinuousDistChart
.
dist
 continuous density function to plota
 lower bound of the interval to plotb
 upper bound of the interval to plotm
 number of points in the plot minus onedesc
 short caption describing the plot
public static String graphDistUnif(cern.colt.list.DoubleArrayList data, String desc)
graphSoft
.
NOTE: see also the more recent class
EmpiricalChart
.
data
 array of observations to plotdesc
 short caption describing the plot
public static String formatp0(double p)
EPSILONP
and replaces p
by ε when it is too small.
p
 the pvalue to be formated
public static String formatp1(double p)
formatp0
to print p, and adds
the marker ``****'' if p is considered suspect
(uses the environment variable SUSPECTP for this).
p
 the pvalue to be formated
public static String formatp2(double x, double p)
formatp1
.
x
 value of the statistic for which the pvalue is formatedp
 the pvalue to be formated
public static String formatp3(String testName, double x, double p)
testName
 name of the test that was performedx
 value of the test statisticp
 pvalue of the test
public static String formatChi2(int k, int d, double chi2)
pDisc
.
k
 number of subintervals for the chisquare testchi2
 chisquare statistic
public static String formatKS(int n, double dp, double dm, double d)
formatp2
for each one.
n
 sample sizedp
 value of the D_{N}^{+} statisticdm
 value of the D_{N}^{} statisticd
 value of the D_{N} statistic
public static String formatKS(cern.colt.list.DoubleArrayList data, ContinuousDistribution dist)
GofStat.kolmogorovSmirnov
(double[],ContinuousDistribution,double[],double[]).
data
 array of observations to be testeddist
 assumed distribution of the observations
public static String formatKSJumpOne(int n, double a, double dp)
formatKS
,
but for the KS statistic D_{N}^{+}(a).
Writes a header,
computes the pvalue and calls formatp2
.
n
 sample sizea
 size of the jumpdp
 value of D_{N}^{+}(a)
public static String formatKSJumpOne(cern.colt.list.DoubleArrayList data, ContinuousDistribution dist, double a)
formatKS
,
but for D_{N}^{+}(a).
data
 array of observations to be testeddist
 assumed distribution of the dataa
 size of the jump
public static void tests(cern.colt.list.DoubleArrayList sortedData, double[] sVal)
GofStat
.
sortedData
 array of sorted observationssVal
 array that will be filled with the results of the testspublic static void tests(cern.colt.list.DoubleArrayList data, ContinuousDistribution dist, double[] sVal)
data
 array of observations to testdist
 assumed distribution of the observationssVal
 array that will be filled with the results of the testspublic static void activeTests(cern.colt.list.DoubleArrayList sortedData, double[] sVal, double[] pVal)
tests
, then computes the pvalues of those
that currently belong to activeTests,
and return these quantities in sVal and pVal, respectively.
Assumes that
U_{(0)},..., U_{(N1)} 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].
sortedData
 array of sorted observationssVal
 array that will be filled with the results of the testspVal
 array that will be filled with the pvaluespublic static void activeTests(cern.colt.list.DoubleArrayList data, ContinuousDistribution dist, double[] sVal, double[] pVal)
data
 array of observations to testdist
 assumed distribution of the observationssVal
 array that will be filled with the results of the testspVal
 array that will be filled with the pvaluespublic static String formatActiveTests(int n, double[] sVal, double[] pVal)
formatp2
for each one.
If n=1, prints only pVal[KSP] using formatp1
.
n
 sample sizesVal
 array containing the results of the testspVal
 array containing the pvalues
public static String iterSpacingsTests(cern.colt.list.DoubleArrayList sortedData, int k, boolean printval, boolean graph, PrintWriter f)
GofStat.iterateSpacings
transformation to the
U_{(0)},..., U_{(N1)}, assuming that these observations are in
sortedData, then computes the EDF test statistics and calls
activeTests
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}.
sortedData
 array containing the sorted observationsk
 number of times the tests are appliedprintval
 if true, stores all the values of the observations at each iterationgraph
 if true, the distribution of the U_{i} will be plotted after each
iterationf
 stream where the plots are written to
public static String iterPowRatioTests(cern.colt.list.DoubleArrayList sortedData, int k, boolean printval, boolean graph, PrintWriter f)
iterSpacingsTests
, but with the
GofStat.powerRatios
transformation.
sortedData
 array containing the sorted observationsk
 number of times the tests are appliedprintval
 if true, stores all the values of the observations at each iterationgraph
 if true, the distribution of the U_{i} will be plotted after each
iterationf
 stream where the plots are written to

SSJ V. 2.6. 

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 