package com.imsl.test.example.stat; import com.imsl.stat.*; /** *
* Performs a Kolmogorov one-sample test. *
* In this example, a random sample of size \(n=100\) is generated using class *Random
for the uniform \((0, 1)\) distribution. We want to test the
* null hypothesis that the cdf is the standard normal distribution with a mean
* of \(0.5\) and a variance equal to the uniform \((0, 1)\) variance \((1/12)\).
*
* @see Code
* @see Output
*/
public class KolmogorovOneSampleEx1 {
static public void main(String arg[]) {
CdfFunction cdf = new CdfFunction() {
public double cdf(double x) {
double mean = 0.5;
double std = 0.2886751;
double z = (x - mean) / std;
return Cdf.normal(z);
}
};
double x[] = new double[100];
Random random = new Random(123457);
random.setMultiplier(16807);
for (int i = 0; i < x.length; i++) {
x[i] = random.nextDouble();
}
KolmogorovOneSample kos = new KolmogorovOneSample(cdf, x);
System.out.println("D = " + kos.getTestStatistic());
System.out.println("D+ = " + kos.getMaximumDifference());
System.out.println("D- = " + kos.getMinimumDifference());
System.out.println("Z = " + kos.getZ());
System.out.println("Prob greater D one sided = "
+ kos.getOneSidedPValue());
System.out.println("Prob greater D two sided = "
+ kos.getTwoSidedPValue());
System.out.println("N missing = " + kos.getNumberMissing());
}
}