示例#1
0
 public static double sumOfLogarithms(double[] elements) {
   double logsum = 0;
   for (int i = 0; i < elements.length; i++) {
     logsum += Math.log(elements[i]);
   }
   return logsum;
 }
示例#2
0
 public static double logGamma(double xx) {
   double[] cof = {
     76.18009172947146,
     -86.50532032941677,
     24.01409824083091,
     -1.231739572450155,
     0.1208650973866179e-2,
     -0.5395239384953e-5
   };
   double x = xx - 1.0;
   double tmp = x + 5.5;
   tmp -= (x + 0.5) * Math.log(tmp);
   double ser = 1.000000000190015;
   double[] coeff = cof;
   for (int j = 0; j <= 5; j++) {
     x++;
     ser += coeff[j] / x;
   }
   return -tmp + Math.log(2.5066282746310005 * ser);
 }