@Reference(title="Fast and accurate computation of binomial probabilities",authors="C. Loader",booktitle="",url="http://projects.scipy.org/scipy/raw-attachment/ticket/620/loader2000Fast.pdf") private static double devianceTerm(double x,double np){
  if (Math.abs(x - np) < 0.1 * (x + np)) {
    final double v=(x - np) / (x + np);
    double s=(x - np) * v;
    double ej=2.0d * x * v;
    for (int j=1; ; j++) {
      ej*=v * v;
      final double s1=s + ej / (2 * j + 1);
      if (s1 == s) {
        return s1;
      }
      s=s1;
    }
  }
  return x * Math.log(x / np) + np - x;
}

@ Reference ( title = "Fast and accurate computation of binomial probabilities" , authors = "C. Loader" , booktitle = "" , url = "http://projects.scipy.org/scipy/raw-attachment/ticket/620/loader2000Fast.pdf" ) private static double devianceTerm ( double x , double np ) { if ( Math . abs ( x - np ) < 0.1 * ( x + np ) ) { final double v = ( x - np ) / ( x + np ) ; double s = ( x - np ) * v ; double ej = 2.0d * x * v ; for ( int j = 1 ; ; j ++ ) { ej *= v * v ; final double s1 = s + ej / ( 2 * j + 1 ) ; if ( s1 == s ) { return s1 ; } s = s1 ; } } return x * Math . log ( x / np ) + np - x ; }
evaluate the deviance term of the saddle point approximation . bd0 ( x , np ) = x * ln ( x / np ) + np - x
