// Test KSdist
System.out.println("Testing KSdist");
// Test special cases
z=0.0;
KSdist norm = new KSdist();
localflag = abs(norm.pks(z)-0.0) > sbeps;
globalflag = globalflag || localflag;
if (localflag) {
fail("*** KSdist: Special case #1 failed for Pks");
}
localflag = abs(norm.qks(z)-1.0) > sbeps;
globalflag = globalflag || localflag;
if (localflag) {
fail("*** KSdist: Special case #1 failed for Qks");
}
z=1.0;
// System.out.printf(setprecision(17) << norm.pks(z) << " %f\n", 1-2.0*exp(-2.0)+2.0*exp(-8.0)-2.0*exp(-18.0));
localflag = abs(norm.pks(z)-1+2.0*exp(-2.0)-2.0*exp(-8.0)+2.0*exp(-18.0)) > sbeps;
globalflag = globalflag || localflag;
if (localflag) {
fail("*** KSdist: Special case #2 failed for Pks");
}
localflag = abs(norm.qks(z)-2.0*exp(-2.0)+2.0*exp(-8.0)-2.0*exp(-18.0)) > sbeps;
globalflag = globalflag || localflag;
if (localflag) {
fail("*** KSdist: Special case #2 failed for Qks");
}
z=100.0;
localflag = abs(norm.pks(z)-1.0) > sbeps;
globalflag = globalflag || localflag;
if (localflag) {
fail("*** KSdist: Special case #3 failed for Pks");
}
localflag = abs(norm.qks(z)-0.0) > sbeps;
globalflag = globalflag || localflag;
if (localflag) {
fail("*** KSdist: Special case #3 failed for Qks");
}
// Pks correctly related to Qks
localflag=false;
for (i=0;i<N;i++)
localflag = localflag || 1.0-norm.pks(x[i])-norm.qks(x[i]) > sbeps;
globalflag = globalflag || localflag;
if (localflag) {
fail("*** KSdist: Pks and Qks do not add to 1.0 in all cases");
}
// inverse of Pks agrees with Pks
Ran myran = new Ran(17);
localflag=false;
sbeps=6.e-10; // XXX 5.e-10 not pass
for (i=0;i<10;i++) {
z=0.3+3.0*myran.doub();
a=norm.pks(z);
b=norm.invpks(a);
// if (abs(z-b) > sbeps) {
// System.out.printf(setprecision(15) << z << " %f\n", b << " %f\n", abs(z-b));
// }
localflag = localflag || abs(z-b) > sbeps;
}
globalflag = globalflag || localflag;
if (localflag) {
fail("*** KSdist: invPks does not accurately invert the Pks");
}
// inverse of Qks agrees with Qks
localflag=false;
sbeps=5.e-10;
for (i=0;i<1000;i++) {
z=0.3+3.0*myran.doub();
a=norm.qks(z);
b=norm.invqks(a);
// if (abs(z-b) > sbeps) {
// System.out.printf(setprecision(15) << z << " %f\n", b << " %f\n", abs(z-b));
// }
localflag = localflag || abs(z-b) > sbeps;
}
globalflag = globalflag || localflag;
if (localflag) {
fail("*** KSdist: invQks does not accurately invert the Qks");
}
// Fingerprint test for Pks
sbeps=1.e-15;
for (i=0;i<N;i++) {
pks[i]=norm.pks(x[i]);
// System.out.printf(setprecision(17) << pks[i]);
}
// System.out.println("KSdist: Maximum discrepancy = %f\n", maxel(vecsub(pks,pksexp)));
localflag = maxel(vecsub(pks,pksexp)) > sbeps;
globalflag = globalflag || localflag;
if (localflag) {
fail("*** KSdist: Fingerprint does not match expectations");
}
// Fingerprint test for Qks
sbeps=1.e-15;
for (i=0;i<N;i++) {
qks[i]=norm.qks(x[i]);
// System.out.printf(setprecision(17) << qks[i]);
}
// System.out.println("KSdist: Maximum discrepancy = %f\n", maxel(vecsub(qks,qksexp)));
localflag = maxel(vecsub(qks,qksexp)) > sbeps;
globalflag = globalflag || localflag;