private static double ppnd(double p){
  double q=p - 0.5;
  double r;
  if (Math.abs(q) <= SPLIT1) {
    r=CONST1 - q * q;
    return q * (((AP3 * r + AP2) * r + AP1) * r + AP0) / (((BP3 * r + BP2) * r + BP1) * r + 1.0);
  }
 else {
    if (q < 0.0) {
      r=p;
    }
 else {
      r=1.0 - p;
    }
    if (r <= 0.0) {
      return 0.0;
    }
    r=Math.sqrt(-Math.log(r));
    double normalDev;
    if (r <= SPLIT2) {
      r-=CONST2;
      normalDev=(((CP3 * r + CP2) * r + CP1) * r + CP0) / ((DP2 * r + DP1) * r + 1.0);
    }
 else {
      r-=SPLIT2;
      normalDev=(((EP3 * r + EP2) * r + EP1) * r + EP0) / ((FP2 * r + FP1) * r + 1.0);
    }
    if (q < 0.0) {
      normalDev=-normalDev;
    }
    return normalDev;
  }
}

private static double ppnd ( double p ) { double q = p - 0.5 ; double r ; if ( Math . abs ( q ) <= SPLIT1 ) { r = CONST1 - q * q ; return q * ( ( ( AP3 * r + AP2 ) * r + AP1 ) * r + AP0 ) / ( ( ( BP3 * r + BP2 ) * r + BP1 ) * r + 1.0 ) ; } else { if ( q < 0.0 ) { r = p ; } else { r = 1.0 - p ; } if ( r <= 0.0 ) { return 0.0 ; } r = Math . sqrt ( - Math . log ( r ) ) ; double normalDev ; if ( r <= SPLIT2 ) { r -= CONST2 ; normalDev = ( ( ( CP3 * r + CP2 ) * r + CP1 ) * r + CP0 ) / ( ( DP2 * r + DP1 ) * r + 1.0 ) ; } else { r -= SPLIT2 ; normalDev = ( ( ( EP3 * r + EP2 ) * r + EP1 ) * r + EP0 ) / ( ( FP2 * r + FP1 ) * r + 1.0 ) ; } if ( q < 0.0 ) { normalDev = - normalDev ; } return normalDev ; } }
algorithm as 241 appl . statist . ( 1988 ) vol . 37 , no . 3 , 477 - 484 . < p > produces the normal deviate z corresponding to a given lower tail area of p ; z is accurate to about 1 part in 10 * * 7 .
