Author: tdunning
Date: Mon Aug 16 14:13:52 2010
New Revision: 985947

URL: http://svn.apache.org/viewvc?rev=985947&view=rev
Log:
Style fixes

Modified:
    mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/stat/Gamma.java

Modified: 
mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/stat/Gamma.java
URL: 
http://svn.apache.org/viewvc/mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/stat/Gamma.java?rev=985947&r1=985946&r2=985947&view=diff
==============================================================================
--- mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/stat/Gamma.java 
(original)
+++ mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/stat/Gamma.java 
Mon Aug 16 14:13:52 2010
@@ -66,30 +66,30 @@ public class Gamma extends org.apache.ma
       y = Math.exp(logGamma(alpha) + logGamma(beta) - logGamma(alpha + beta));
     }
 
-    return (y);
+    return y;
   }
 
   /** Returns the Gamma function of the argument. */
-  public static double gamma(double x) throws ArithmeticException {
+  public static double gamma(double x) {
 
-    double[] P = {
-        1.60119522476751861407E-4,
-        1.19135147006586384913E-3,
-        1.04213797561761569935E-2,
-        4.76367800457137231464E-2,
-        2.07448227648435975150E-1,
-        4.94214826801497100753E-1,
-        9.99999999999999996796E-1
+    double[] pCoefficient = {
+      1.60119522476751861407E-4,
+      1.19135147006586384913E-3,
+      1.04213797561761569935E-2,
+      4.76367800457137231464E-2,
+      2.07448227648435975150E-1,
+      4.94214826801497100753E-1,
+      9.99999999999999996796E-1
     };
-    double[] Q = {
-        -2.31581873324120129819E-5,
-        5.39605580493303397842E-4,
-        -4.45641913851797240494E-3,
-        1.18139785222060435552E-2,
-        3.58236398605498653373E-2,
-        -2.34591795718243348568E-1,
-        7.14304917030273074085E-2,
-        1.00000000000000000320E0
+    double[] qCoefficient = {
+      -2.31581873324120129819E-5,
+      5.39605580493303397842E-4,
+      -4.45641913851797240494E-3,
+      1.18139785222060435552E-2,
+      3.58236398605498653373E-2,
+      -2.34591795718243348568E-1,
+      7.14304917030273074085E-2,
+      1.00000000000000000320E0
     };
 //double MAXGAM = 171.624376956302725;
 //double LOGPI  = 1.14472988584940017414;
@@ -134,7 +134,7 @@ public class Gamma extends org.apache.ma
       if (x == 0.0) {
         throw new ArithmeticException("gamma: singular");
       } else if (x > -1.0e-9) {
-        return (z / ((1.0 + 0.5772156649015329 * x) * x));
+        return z / ((1.0 + 0.5772156649015329 * x) * x);
       }
       z /= x;
       x += 1.0;
@@ -144,7 +144,7 @@ public class Gamma extends org.apache.ma
       if (x == 0.0) {
         throw new ArithmeticException("gamma: singular");
       } else if (x < 1.0e-9) {
-        return (z / ((1.0 + 0.5772156649015329 * x) * x));
+        return z / ((1.0 + 0.5772156649015329 * x) * x);
       }
       z /= x;
       x += 1.0;
@@ -155,8 +155,8 @@ public class Gamma extends org.apache.ma
     }
 
     x -= 2.0;
-    p = Polynomial.polevl(x, P, 6);
-    q = Polynomial.polevl(x, Q, 7);
+    p = Polynomial.polevl(x, pCoefficient, 6);
+    q = Polynomial.polevl(x, qCoefficient, 7);
     return z * p / q;
 
   }
@@ -170,7 +170,7 @@ public class Gamma extends org.apache.ma
    * @param beta the beta parameter of the beta distribution.
    * @param xx the integration end point.
    */
-  public static double incompleteBeta(double alpha, double beta, double xx) 
throws ArithmeticException {
+  public static double incompleteBeta(double alpha, double beta, double xx) {
 
     if (alpha <= 0.0) {
       throw new ArithmeticException("incompleteBeta: Domain error! alpha must 
be > 0, but was " + alpha);
@@ -254,7 +254,7 @@ public class Gamma extends org.apache.ma
   }
 
   /** Continued fraction expansion #1 for incomplete beta integral; formerly 
named <tt>incbcf</tt>. */
-  static double incompleteBetaFraction1(double a, double b, double x) throws 
ArithmeticException {
+  static double incompleteBetaFraction1(double a, double b, double x) {
 
     double k1 = a;
     double k2 = a + b;
@@ -332,7 +332,7 @@ public class Gamma extends org.apache.ma
   }
 
   /** Continued fraction expansion #2 for incomplete beta integral; formerly 
named <tt>incbd</tt>. */
-  static double incompleteBetaFraction2(double a, double b, double x) throws 
ArithmeticException {
+  static double incompleteBetaFraction2(double a, double b, double x) {
 
     double k1 = a;
     double k2 = b - 1.0;
@@ -417,7 +417,7 @@ public class Gamma extends org.apache.ma
    * @param x the integration end point.
    * @return The value of the unnormalized incomplete gamma function.
    */
-  public static double incompleteGamma(double alpha, double x){
+  public static double incompleteGamma(double alpha, double x) {
     if (x <= 0 || alpha <= 0) {
       return 0.0;
     }
@@ -429,7 +429,7 @@ public class Gamma extends org.apache.ma
     /* Compute  x**a * exp(-x) / gamma(a)  */
     double ax = alpha * Math.log(x) - x - logGamma(alpha);
     if (ax < -MAXLOG) {
-      return (0.0);
+      return 0.0;
     }
 
     ax = Math.exp(ax);
@@ -446,7 +446,7 @@ public class Gamma extends org.apache.ma
     }
     while (c / ans > MACHEP);
 
-    return (ans * ax / alpha);
+    return ans * ax / alpha;
 
   }
 
@@ -520,29 +520,29 @@ public class Gamma extends org.apache.ma
     double q;
     double z;
 
-    double[] A = {
-        8.11614167470508450300E-4,
-        -5.95061904284301438324E-4,
-        7.93650340457716943945E-4,
-        -2.77777777730099687205E-3,
-        8.33333333333331927722E-2
+    double[] aCoefficient = {
+      8.11614167470508450300E-4,
+      -5.95061904284301438324E-4,
+      7.93650340457716943945E-4,
+      -2.77777777730099687205E-3,
+      8.33333333333331927722E-2
     };
-    double[] B = {
-        -1.37825152569120859100E3,
-        -3.88016315134637840924E4,
-        -3.31612992738871184744E5,
-        -1.16237097492762307383E6,
-        -1.72173700820839662146E6,
-        -8.53555664245765465627E5
+    double[] bCoefficient = {
+      -1.37825152569120859100E3,
+      -3.88016315134637840924E4,
+      -3.31612992738871184744E5,
+      -1.16237097492762307383E6,
+      -1.72173700820839662146E6,
+      -8.53555664245765465627E5
     };
-    double[] C = {
-        /* 1.00000000000000000000E0, */
-        -3.51815701436523470549E2,
-        -1.70642106651881159223E4,
-        -2.20528590553854454839E5,
-        -1.13933444367982507207E6,
-        -2.53252307177582951285E6,
-        -2.01889141433532773231E6
+    double[] cCoefficient = {
+      /* 1.00000000000000000000E0, */
+      -3.51815701436523470549E2,
+      -1.70642106651881159223E4,
+      -2.20528590553854454839E5,
+      -1.13933444367982507207E6,
+      -2.53252307177582951285E6,
+      -2.01889141433532773231E6
     };
 
     if (x < -34.0) {
@@ -574,8 +574,7 @@ public class Gamma extends org.apache.ma
       }
       while (x < 2.0) {
         if (x == 0.0) {
-          throw new
-              ArithmeticException("lgamma: Overflow");
+          throw new ArithmeticException("lgamma: Overflow");
         }
         z /= x;
         x += 1.0;
@@ -587,19 +586,18 @@ public class Gamma extends org.apache.ma
         return Math.log(z);
       }
       x -= 2.0;
-      p = x * Polynomial.polevl(x, B, 5) / Polynomial.p1evl(x, C, 6);
-      return (Math.log(z) + p);
+      p = x * Polynomial.polevl(x, bCoefficient, 5) / Polynomial.p1evl(x, 
cCoefficient, 6);
+      return Math.log(z) + p;
     }
 
     if (x > 2.556348e305) {
-      throw new
-          ArithmeticException("lgamma: Overflow");
+      throw new ArithmeticException("lgamma: Overflow");
     }
 
     q = (x - 0.5) * Math.log(x) - x + 0.91893853320467274178;
     //if( x > 1.0e8 ) return( q );
     if (x > 1.0e8) {
-      return (q);
+      return q;
     }
 
     p = 1.0 / (x * x);
@@ -608,7 +606,7 @@ public class Gamma extends org.apache.ma
           - 2.7777777777777777777778e-3) * p
           + 0.0833333333333333333333) / x;
     } else {
-      q += Polynomial.polevl(p, A, 4) / x;
+      q += Polynomial.polevl(p, aCoefficient, 4) / x;
     }
     return q;
   }
@@ -617,7 +615,7 @@ public class Gamma extends org.apache.ma
    * Power series for incomplete beta integral; formerly named 
<tt>pseries</tt>. Use when b*x is small and x not too
    * close to 1.
    */
-  private static double powerSeries(double a, double b, double x) throws 
ArithmeticException {
+  private static double powerSeries(double a, double b, double x) {
 
     double ai = 1.0 / a;
     double u = (1.0 - b) * x;
@@ -652,19 +650,19 @@ public class Gamma extends org.apache.ma
    * Returns the Gamma function computed by Stirling's formula; formerly named 
<tt>stirf</tt>. The polynomial STIR is
    * valid for 33 <= x <= 172.
    */
-  static double stirlingFormula(double x) throws ArithmeticException {
-    double[] STIR = {
-        7.87311395793093628397E-4,
-        -2.29549961613378126380E-4,
-        -2.68132617805781232825E-3,
-        3.47222221605458667310E-3,
-        8.33333333333482257126E-2,
+  static double stirlingFormula(double x) {
+    double[] coefficients = {
+      7.87311395793093628397E-4,
+      -2.29549961613378126380E-4,
+      -2.68132617805781232825E-3,
+      3.47222221605458667310E-3,
+      8.33333333333482257126E-2,
     };
 
     double w = 1.0 / x;
     double y = Math.exp(x);
 
-    w = 1.0 + w * Polynomial.polevl(w, STIR, 4);
+    w = 1.0 + w * Polynomial.polevl(w, coefficients, 4);
 
     double MAXSTIR = 143.01608;
     if (x > MAXSTIR) {


Reply via email to