Quadvl quadvl = new Quadvl();
// Test ks2d1s
System.out.println("Testing ks2d1s");
Ran myran=new Ran(17);
for (i=0;i<NTRIAL;i++) {
for (j=1;j<NPT;j++)
x[j]=2.0*myran.doub()-1.0;
for (j=1;j<NPT;j++)
y[j]=2.0*myran.doub()-1.0;
ks2d1s(x,y,quadvl,dd,pprob);
d[i]=dd.val;
prob[i]=pprob.val;
}
// Note: It was observed that qualitatively if the probabilities
// are ordered,and then g[i]=p[i]*(2=p[i]), the result is approximately
// distributed uniformly from 0.0 to 1.0
Sorter.sort2(d,prob);
rms=0.0;
for (i=0;i<NTRIAL;i++) {
f[i]=(double)(NTRIAL-i)/NTRIAL;
g[i]=prob[i]*(2.0-prob[i]);
rms += SQR(f[i]-g[i]);
// System.out.printf(prob[i] << " %f\n", f[i] << " %f\n", g[i]);
// System.out.printf(i << " %f\n", d[i] << " %f\n", prob[i]);
}
rms=sqrt(rms/NTRIAL);
System.out.printf("rms: %f\n", rms);
sbeps = 0.08;
localflag = rms > sbeps;
globalflag = globalflag || localflag;
if (localflag) {
fail("*** ks2d1s: Result deviated from a qualitative model");
}
// Distort the distribution
factor=0.2;
ave=0.0;
for (i=0;i<NTRIAL;i++) {
for (j=1;j<NPT;j++) {
u=myran.doub();
u=u*((1-factor)+u*factor);
x[j]=2.0*u-1.0;
}
for (j=1;j<NPT;j++) {
u=myran.doub();
u=u*((1-factor)+u*factor);
y[j]=2.0*myran.doub()-1.0;
}
ks2d1s(x,y,quadvl,dd,pprob);
ave += pprob.val;
}
ave /= NTRIAL;