private static double estimateKSCriticalValue(int level,int n){
  double criticalValue=0.0;
  if (n <= 35) {
    if (n >= 20 && n < 25)     n=20;
    if (n >= 25 && n < 30)     n=25;
    if (n >= 30 && n < 35)     n=30;
    double table[]=new double[36];
switch (level) {
case (1):
      table[1]=.900;
    table[2]=.684;
  table[3]=.565;
table[4]=.494;
table[5]=.446;
table[6]=.410;
table[7]=.381;
table[8]=.358;
table[9]=.339;
table[10]=.322;
table[11]=.307;
table[12]=.295;
table[13]=.284;
table[14]=.274;
table[15]=.266;
table[16]=.258;
table[17]=.250;
table[18]=.244;
table[19]=.237;
table[20]=.231;
table[25]=.210;
table[30]=.190;
table[35]=.180;
break;
case (2):
table[1]=.925;
table[2]=.726;
table[3]=.597;
table[4]=.525;
table[5]=.474;
table[6]=.436;
table[7]=.405;
table[8]=.381;
table[9]=.360;
table[10]=.342;
table[11]=.326;
table[12]=.313;
table[13]=.302;
table[14]=.292;
table[15]=.283;
table[16]=.274;
table[17]=.266;
table[18]=.259;
table[19]=.252;
table[20]=.246;
table[25]=.220;
table[30]=.200;
table[35]=.190;
break;
case (3):
table[1]=.950;
table[2]=.776;
table[3]=.642;
table[4]=.564;
table[5]=.510;
table[6]=.470;
table[7]=.438;
table[8]=.411;
table[9]=.388;
table[10]=.368;
table[11]=.352;
table[12]=.338;
table[13]=.325;
table[14]=.314;
table[15]=.304;
table[16]=.295;
table[17]=.286;
table[18]=.278;
table[19]=.272;
table[20]=.264;
table[25]=.240;
table[30]=.220;
table[35]=.210;
break;
case (4):
table[1]=.975;
table[2]=.842;
table[3]=.708;
table[4]=.624;
table[5]=.565;
table[6]=.521;
table[7]=.486;
table[8]=.457;
table[9]=.432;
table[10]=.410;
table[11]=.391;
table[12]=.375;
table[13]=.361;
table[14]=.349;
table[15]=.338;
table[16]=.328;
table[17]=.318;
table[18]=.309;
table[19]=.301;
table[20]=.294;
table[25]=.270;
table[30]=.240;
table[35]=.230;
break;
case (5):
table[1]=.995;
table[2]=.929;
table[3]=.828;
table[4]=.733;
table[5]=.669;
table[6]=.618;
table[7]=.577;
table[8]=.543;
table[9]=.514;
table[10]=.490;
table[11]=.468;
table[12]=.450;
table[13]=.433;
table[14]=.418;
table[15]=.404;
table[16]=.392;
table[17]=.381;
table[18]=.371;
table[19]=.363;
table[20]=.356;
table[25]=.320;
table[30]=.290;
table[35]=.270;
break;
}
criticalValue=table[n];
}
 else {
switch (level) {
case (1):
criticalValue=1.07 / Math.sqrt(n);
break;
case (2):
criticalValue=1.14 / Math.sqrt(n);
break;
case (3):
criticalValue=1.22 / Math.sqrt(n);
break;
case (4):
criticalValue=1.36 / Math.sqrt(n);
break;
case (5):
criticalValue=1.63 / Math.sqrt(n);
break;
}
}
return criticalValue;
}

private static double estimateKSCriticalValue ( int level , int n ) { double criticalValue = 0.0 ; if ( n <= 35 ) { if ( n >= 20 && n < 25 ) n = 20 ; if ( n >= 25 && n < 30 ) n = 25 ; if ( n >= 30 && n < 35 ) n = 30 ; double table [ ] = new double [ 36 ] ; switch ( level ) { case ( 1 ) : table [ 1 ] = .900 ; table [ 2 ] = .684 ; table [ 3 ] = .565 ; table [ 4 ] = .494 ; table [ 5 ] = .446 ; table [ 6 ] = .410 ; table [ 7 ] = .381 ; table [ 8 ] = .358 ; table [ 9 ] = .339 ; table [ 10 ] = .322 ; table [ 11 ] = .307 ; table [ 12 ] = .295 ; table [ 13 ] = .284 ; table [ 14 ] = .274 ; table [ 15 ] = .266 ; table [ 16 ] = .258 ; table [ 17 ] = .250 ; table [ 18 ] = .244 ; table [ 19 ] = .237 ; table [ 20 ] = .231 ; table [ 25 ] = .210 ; table [ 30 ] = .190 ; table [ 35 ] = .180 ; break ; case ( 2 ) : table [ 1 ] = .925 ; table [ 2 ] = .726 ; table [ 3 ] = .597 ; table [ 4 ] = .525 ; table [ 5 ] = .474 ; table [ 6 ] = .436 ; table [ 7 ] = .405 ; table [ 8 ] = .381 ; table [ 9 ] = .360 ; table [ 10 ] = .342 ; table [ 11 ] = .326 ; table [ 12 ] = .313 ; table [ 13 ] = .302 ; table [ 14 ] = .292 ; table [ 15 ] = .283 ; table [ 16 ] = .274 ; table [ 17 ] = .266 ; table [ 18 ] = .259 ; table [ 19 ] = .252 ; table [ 20 ] = .246 ; table [ 25 ] = .220 ; table [ 30 ] = .200 ; table [ 35 ] = .190 ; break ; case ( 3 ) : table [ 1 ] = .950 ; table [ 2 ] = .776 ; table [ 3 ] = .642 ; table [ 4 ] = .564 ; table [ 5 ] = .510 ; table [ 6 ] = .470 ; table [ 7 ] = .438 ; table [ 8 ] = .411 ; table [ 9 ] = .388 ; table [ 10 ] = .368 ; table [ 11 ] = .352 ; table [ 12 ] = .338 ; table [ 13 ] = .325 ; table [ 14 ] = .314 ; table [ 15 ] = .304 ; table [ 16 ] = .295 ; table [ 17 ] = .286 ; table [ 18 ] = .278 ; table [ 19 ] = .272 ; table [ 20 ] = .264 ; table [ 25 ] = .240 ; table [ 30 ] = .220 ; table [ 35 ] = .210 ; break ; case ( 4 ) : table [ 1 ] = .975 ; table [ 2 ] = .842 ; table [ 3 ] = .708 ; table [ 4 ] = .624 ; table [ 5 ] = .565 ; table [ 6 ] = .521 ; table [ 7 ] = .486 ; table [ 8 ] = .457 ; table [ 9 ] = .432 ; table [ 10 ] = .410 ; table [ 11 ] = .391 ; table [ 12 ] = .375 ; table [ 13 ] = .361 ; table [ 14 ] = .349 ; table [ 15 ] = .338 ; table [ 16 ] = .328 ; table [ 17 ] = .318 ; table [ 18 ] = .309 ; table [ 19 ] = .301 ; table [ 20 ] = .294 ; table [ 25 ] = .270 ; table [ 30 ] = .240 ; table [ 35 ] = .230 ; break ; case ( 5 ) : table [ 1 ] = .995 ; table [ 2 ] = .929 ; table [ 3 ] = .828 ; table [ 4 ] = .733 ; table [ 5 ] = .669 ; table [ 6 ] = .618 ; table [ 7 ] = .577 ; table [ 8 ] = .543 ; table [ 9 ] = .514 ; table [ 10 ] = .490 ; table [ 11 ] = .468 ; table [ 12 ] = .450 ; table [ 13 ] = .433 ; table [ 14 ] = .418 ; table [ 15 ] = .404 ; table [ 16 ] = .392 ; table [ 17 ] = .381 ; table [ 18 ] = .371 ; table [ 19 ] = .363 ; table [ 20 ] = .356 ; table [ 25 ] = .320 ; table [ 30 ] = .290 ; table [ 35 ] = .270 ; break ; } criticalValue = table [ n ] ; } else { switch ( level ) { case ( 1 ) : criticalValue = 1.07 / Math . sqrt ( n ) ; break ; case ( 2 ) : criticalValue = 1.14 / Math . sqrt ( n ) ; break ; case ( 3 ) : criticalValue = 1.22 / Math . sqrt ( n ) ; break ; case ( 4 ) : criticalValue = 1.36 / Math . sqrt ( n ) ; break ; case ( 5 ) : criticalValue = 1.63 / Math . sqrt ( n ) ; break ; } } return criticalValue ; }
calculates the k - s critical value
