public static double logcdf(double val,double loc,double scale){
  val=(val - loc) / scale;
  if (val <= 18.) {
    return -Math.log1p(Math.exp(-val));
  }
 else   if (val > 33.3) {
    return val;
  }
 else {
    return val - Math.exp(val);
  }
}

public static double logcdf ( double val , double loc , double scale ) { val = ( val - loc ) / scale ; if ( val <= 18. ) { return - Math . log1p ( Math . exp ( - val ) ) ; } else if ( val > 33.3 ) { return val ; } else { return val - Math . exp ( val ) ; } }
log cumulative density function . todo : untested .
