You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mahout.apache.org by sr...@apache.org on 2010/09/07 15:54:24 UTC

svn commit: r993365 [2/3] - in /mahout/trunk: core/src/main/java/org/apache/mahout/cf/taste/hadoop/ core/src/main/java/org/apache/mahout/classifier/bayes/ core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/cbayes/ core/src/main/java/org/ap...

Modified: mahout/trunk/core/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopyCreatorMapper.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopyCreatorMapper.java?rev=993365&r1=993364&r2=993365&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopyCreatorMapper.java (original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopyCreatorMapper.java Tue Sep  7 13:54:21 2010
@@ -47,19 +47,19 @@ public class MeanShiftCanopyCreatorMappe
     String measureClass = context.getConfiguration().get(KMeansConfigKeys.DISTANCE_MEASURE_KEY);
     ClassLoader ccl = Thread.currentThread().getContextClassLoader();
     try {
-      measure = (DistanceMeasure) ((Class<?>) ccl.loadClass(measureClass)).newInstance();
+      measure = ccl.loadClass(measureClass).asSubclass(DistanceMeasure.class).newInstance();
     } catch (InstantiationException e) {
-      new IllegalStateException(e);
+      throw new IllegalStateException(e);
     } catch (IllegalAccessException e) {
-      new IllegalStateException(e);
+      throw new IllegalStateException(e);
     } catch (ClassNotFoundException e) {
-      new IllegalStateException(e);
+      throw new IllegalStateException(e);
     }
 
     if (nextCanopyId == -1) {
       String taskId = context.getConfiguration().get("mapred.task.id");
       String[] parts = UNDERSCORE_PATTERN.split(taskId);
-      if (parts.length != 6 || !parts[0].equals("attempt") || (!"m".equals(parts[3]) && !"r".equals(parts[3]))) {
+      if (parts.length != 6 || !"attempt".equals(parts[0]) || (!"m".equals(parts[3]) && !"r".equals(parts[3]))) {
         throw new IllegalArgumentException("TaskAttemptId string : " + taskId + " is not properly formed");
       }
       nextCanopyId = ((1 << 31) / 50000) * (Integer.parseInt(parts[4]));

Modified: mahout/trunk/core/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopyDriver.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopyDriver.java?rev=993365&r1=993364&r2=993365&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopyDriver.java (original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopyDriver.java Tue Sep  7 13:54:21 2010
@@ -144,7 +144,7 @@ public class MeanShiftCanopyDriver exten
     boolean runSequential = (getOption(DefaultOptionCreator.METHOD_OPTION).equalsIgnoreCase(
         DefaultOptionCreator.SEQUENTIAL_METHOD));
     ClassLoader ccl = Thread.currentThread().getContextClassLoader();
-    DistanceMeasure measure = (DistanceMeasure) ((Class<?>) ccl.loadClass(measureClass)).newInstance();
+    DistanceMeasure measure = ccl.loadClass(measureClass).asSubclass(DistanceMeasure.class).newInstance();
 
     job(input,
         output,
@@ -292,10 +292,10 @@ public class MeanShiftCanopyDriver exten
                                                            MeanShiftCanopy.class);
       try {
         Writable key = reader.getKeyClass().asSubclass(Writable.class).newInstance();
-        VectorWritable vw = (VectorWritable) reader.getValueClass().newInstance();
+        VectorWritable vw = reader.getValueClass().asSubclass(VectorWritable.class).newInstance();
         while (reader.next(key, vw)) {
           writer.append(new Text(), new MeanShiftCanopy(vw.get(), id++, measure));
-          vw = (VectorWritable) reader.getValueClass().newInstance();
+          vw = reader.getValueClass().asSubclass(VectorWritable.class).newInstance();
         }
       } finally {
         reader.close();
@@ -375,10 +375,10 @@ public class MeanShiftCanopyDriver exten
       SequenceFile.Reader reader = new SequenceFile.Reader(fs, s.getPath(), conf);
       try {
         Writable key = reader.getKeyClass().asSubclass(Writable.class).newInstance();
-        MeanShiftCanopy canopy = (MeanShiftCanopy) reader.getValueClass().newInstance();
+        MeanShiftCanopy canopy = reader.getValueClass().asSubclass(MeanShiftCanopy.class).newInstance();
         while (reader.next(key, canopy)) {
           clusterer.mergeCanopy(canopy, clusters);
-          canopy = (MeanShiftCanopy) reader.getValueClass().newInstance();
+          canopy = reader.getValueClass().asSubclass(MeanShiftCanopy.class).newInstance();
         }
       } finally {
         reader.close();
@@ -414,7 +414,7 @@ public class MeanShiftCanopyDriver exten
     return clustersIn;
   }
 
-  private Path buildClustersMR(Path clustersIn,
+  private static Path buildClustersMR(Path clustersIn,
                                       Path output,
                                       DistanceMeasure measure,
                                       double t1,
@@ -472,10 +472,10 @@ public class MeanShiftCanopyDriver exten
       SequenceFile.Reader reader = new SequenceFile.Reader(fs, s.getPath(), conf);
       try {
         Writable key = reader.getKeyClass().asSubclass(Writable.class).newInstance();
-        MeanShiftCanopy value = (MeanShiftCanopy) reader.getValueClass().newInstance();
+        MeanShiftCanopy value = reader.getValueClass().asSubclass(MeanShiftCanopy.class).newInstance();
         while (reader.next(key, value)) {
           clusters.add(value);
-          value = (MeanShiftCanopy) reader.getValueClass().newInstance();
+          value = reader.getValueClass().asSubclass(MeanShiftCanopy.class).newInstance();
         }
       } finally {
         reader.close();
@@ -495,12 +495,12 @@ public class MeanShiftCanopyDriver exten
                                                            WeightedVectorWritable.class);
       try {
         Writable key = reader.getKeyClass().asSubclass(Writable.class).newInstance();
-        MeanShiftCanopy canopy = (MeanShiftCanopy) reader.getValueClass().newInstance();
+        MeanShiftCanopy canopy = reader.getValueClass().asSubclass(MeanShiftCanopy.class).newInstance();
         while (reader.next(key, canopy)) {
           MeanShiftCanopy closest = MeanShiftCanopyClusterer.findCoveringCanopy(canopy, clusters);
           writer.append(new IntWritable(closest.getId()),
                         new WeightedVectorWritable(1, new VectorWritable(canopy.getCenter())));
-          canopy = (MeanShiftCanopy) reader.getValueClass().newInstance();
+          canopy = reader.getValueClass().asSubclass(MeanShiftCanopy.class).newInstance();
         }
       } finally {
         reader.close();

Modified: mahout/trunk/core/src/main/java/org/apache/mahout/common/IntPairWritable.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/common/IntPairWritable.java?rev=993365&r1=993364&r2=993365&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/common/IntPairWritable.java (original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/common/IntPairWritable.java Tue Sep  7 13:54:21 2010
@@ -146,7 +146,7 @@ public final class IntPairWritable
     WritableComparator.define(IntPairWritable.class, new Comparator());
   }
 
-  public static final class Comparator extends WritableComparator {
+  public static final class Comparator extends WritableComparator implements Serializable {
     public Comparator() {
       super(IntPairWritable.class);
     }
@@ -185,7 +185,7 @@ public final class IntPairWritable
   /**
    * Compare only the first part of the pair, so that reduce is called once for each value of the first part.
    */
-  public static class FirstGroupingComparator extends WritableComparator {
+  public static class FirstGroupingComparator extends WritableComparator implements Serializable {
     
     public FirstGroupingComparator() {
       super(IntPairWritable.class);

Modified: mahout/trunk/core/src/main/java/org/apache/mahout/df/data/DataConverter.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/df/data/DataConverter.java?rev=993365&r1=993364&r2=993365&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/df/data/DataConverter.java (original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/df/data/DataConverter.java Tue Sep  7 13:54:21 2010
@@ -18,7 +18,6 @@
 package org.apache.mahout.df.data;
 
 import java.util.Arrays;
-import java.util.Locale;
 import java.util.StringTokenizer;
 
 import org.apache.commons.lang.ArrayUtils;

Modified: mahout/trunk/core/src/main/java/org/apache/mahout/df/mapreduce/inmem/InMemInputFormat.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/df/mapreduce/inmem/InMemInputFormat.java?rev=993365&r1=993364&r2=993365&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/df/mapreduce/inmem/InMemInputFormat.java (original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/df/mapreduce/inmem/InMemInputFormat.java Tue Sep  7 13:54:21 2010
@@ -226,7 +226,7 @@ public class InMemInputFormat extends In
       if (this == obj) {
         return true;
       }
-      if ((obj == null) || !(obj instanceof InMemInputSplit)) {
+      if (!(obj instanceof InMemInputSplit)) {
         return false;
       }
       

Modified: mahout/trunk/core/src/main/java/org/apache/mahout/ep/State.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/ep/State.java?rev=993365&r1=993364&r2=993365&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/ep/State.java (original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/ep/State.java Tue Sep  7 13:54:21 2010
@@ -219,7 +219,15 @@ public class State<T extends Payload<T>>
   @Override
   public int compareTo(State<T> other) {
     int r = Double.compare(other.value, this.value);
-    return r == 0 ? this.id - other.id : r;
+    if (r != 0) {
+      return r;
+    }
+    if (this.id < other.id) {
+      return -1;
+    } else if (this.id > other.id) {
+      return 1;
+    }
+    return 0;
   }
 
   public String toString() {

Modified: mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/fpgrowth/FPGrowth.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/fpgrowth/FPGrowth.java?rev=993365&r1=993364&r2=993365&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/fpgrowth/FPGrowth.java (original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/fpgrowth/FPGrowth.java Tue Sep  7 13:54:21 2010
@@ -367,17 +367,15 @@ public class FPGrowth<A extends Comparab
           treeCache, level + 1, true, currentAttribute, updater);
 
         frequentPatterns = mergeHeap(frequentPatterns, returnedPatterns,
-          attribute, count, true, true);
+          attribute, count, true);
       } else {
         returnedPatterns = growthTopDown(conditionalTree, minSupportMutable, k,
           treeCache, level + 1, false, currentAttribute, updater);
         frequentPatterns = mergeHeap(frequentPatterns, returnedPatterns,
-          attribute, count, false, true);
+          attribute, count, false);
       }
-      if (frequentPatterns.isFull()) {
-        if (minSupportMutable.intValue() < frequentPatterns.leastSupport()) {
-          minSupportMutable.setValue(frequentPatterns.leastSupport());
-        }
+      if (frequentPatterns.isFull() && minSupportMutable.intValue() < frequentPatterns.leastSupport()) {
+        minSupportMutable.setValue(frequentPatterns.leastSupport());
       }
       i++;
     }
@@ -432,7 +430,7 @@ public class FPGrowth<A extends Comparab
           k, treeCache, level + 1, true, currentAttribute, updater);
 
         frequentPatterns = mergeHeap(frequentPatterns, returnedPatterns,
-          attribute, count, true, false);
+          attribute, count, true);
       } else {
         if (attribute == currentAttribute) {
           traverseAndBuildConditionalFPTreeData(tree.getHeaderNext(attribute),
@@ -441,21 +439,19 @@ public class FPGrowth<A extends Comparab
             k, treeCache, level + 1, true, currentAttribute, updater);
 
           frequentPatterns = mergeHeap(frequentPatterns, returnedPatterns,
-            attribute, count, true, false);
+            attribute, count, true);
         } else if (attribute > currentAttribute) {
           traverseAndBuildConditionalFPTreeData(tree.getHeaderNext(attribute),
             minSupportMutable, conditionalTree, tree);
           returnedPatterns = growthBottomUp(conditionalTree, minSupportMutable,
             k, treeCache, level + 1, false, currentAttribute, updater);
           frequentPatterns = mergeHeap(frequentPatterns, returnedPatterns,
-            attribute, count, false, false);
+            attribute, count, false);
         }
       }
 
-      if (frequentPatterns.isFull()) {
-        if (minSupportMutable.intValue() < frequentPatterns.leastSupport()) {
-          minSupportMutable.setValue(frequentPatterns.leastSupport());
-        }
+      if (frequentPatterns.isFull() && minSupportMutable.intValue() < frequentPatterns.leastSupport()) {
+        minSupportMutable.setValue(frequentPatterns.leastSupport());
       }
     }
 
@@ -511,7 +507,7 @@ public class FPGrowth<A extends Comparab
         returnedPatterns = growthBottomUp(conditionalTree, minSupportMutable,
           k, treeCache, level + 1, true, currentAttribute, updater);
         frequentPatterns = mergeHeap(frequentPatterns, returnedPatterns,
-          attribute, count, true, true);
+          attribute, count, true);
 
       } else {
         if (attribute == currentAttribute) {
@@ -520,7 +516,7 @@ public class FPGrowth<A extends Comparab
           returnedPatterns = growthBottomUp(conditionalTree, minSupportMutable,
             k, treeCache, level + 1, true, currentAttribute, updater);
           frequentPatterns = mergeHeap(frequentPatterns, returnedPatterns,
-            attribute, count, true, false);
+            attribute, count, true);
 
         } else if (attribute > currentAttribute) {
           traverseAndBuildConditionalFPTreeData(tree.getHeaderNext(attribute),
@@ -528,14 +524,12 @@ public class FPGrowth<A extends Comparab
           returnedPatterns = growthBottomUp(conditionalTree, minSupportMutable,
             k, treeCache, level + 1, false, currentAttribute, updater);
           frequentPatterns = mergeHeap(frequentPatterns, returnedPatterns,
-            attribute, count, false, true);
+            attribute, count, false);
 
         }
       }
-      if (frequentPatterns.isFull()) {
-        if (minSupportMutable.intValue() < frequentPatterns.leastSupport()) {
-          minSupportMutable.setValue(frequentPatterns.leastSupport());
-        }
+      if (frequentPatterns.isFull() && minSupportMutable.intValue() < frequentPatterns.leastSupport()) {
+        minSupportMutable.setValue(frequentPatterns.leastSupport());
       }
     }
 
@@ -546,8 +540,7 @@ public class FPGrowth<A extends Comparab
                                                   FrequentPatternMaxHeap returnedPatterns,
                                                   int attribute,
                                                   long count,
-                                                  boolean addAttribute,
-                                                  boolean subPatternCheck) {
+                                                  boolean addAttribute) {
     frequentPatterns.addAll(returnedPatterns, attribute, count);
     if (frequentPatterns.addable(count) && addAttribute) {
       Pattern p = new Pattern();

Modified: mahout/trunk/core/src/main/java/org/apache/mahout/math/hadoop/decomposer/EigenVerificationJob.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/math/hadoop/decomposer/EigenVerificationJob.java?rev=993365&r1=993364&r2=993365&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/math/hadoop/decomposer/EigenVerificationJob.java (original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/math/hadoop/decomposer/EigenVerificationJob.java Tue Sep  7 13:54:21 2010
@@ -110,7 +110,8 @@ public class EigenVerificationJob extend
 
     eigenVerifier = new SimpleEigenVerifier();
 
-    VectorIterable pairwiseInnerProducts = computePairwiseInnerProducts();
+    //VectorIterable pairwiseInnerProducts = computePairwiseInnerProducts();
+    computePairwiseInnerProducts();
 
     Map<MatrixSlice,EigenStatus> eigenMetaData = verifyEigens();
 

Modified: mahout/trunk/core/src/main/java/org/apache/mahout/math/hadoop/similarity/RowSimilarityJob.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/math/hadoop/similarity/RowSimilarityJob.java?rev=993365&r1=993364&r2=993365&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/math/hadoop/similarity/RowSimilarityJob.java (original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/math/hadoop/similarity/RowSimilarityJob.java Tue Sep  7 13:54:21 2010
@@ -178,7 +178,7 @@ public class RowSimilarityJob extends Ab
 
   static DistributedVectorSimilarity instantiateSimilarity(String classname) {
     try {
-      return (DistributedVectorSimilarity) Class.forName(classname).newInstance();
+      return Class.forName(classname).asSubclass(DistributedVectorSimilarity.class).newInstance();
     } catch (ClassNotFoundException cnfe) {
       throw new IllegalStateException(cnfe);
     } catch (InstantiationException ie) {

Modified: mahout/trunk/core/src/main/java/org/apache/mahout/math/hadoop/similarity/SimilarityMatrixEntryKey.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/math/hadoop/similarity/SimilarityMatrixEntryKey.java?rev=993365&r1=993364&r2=993365&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/math/hadoop/similarity/SimilarityMatrixEntryKey.java (original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/math/hadoop/similarity/SimilarityMatrixEntryKey.java Tue Sep  7 13:54:21 2010
@@ -20,6 +20,7 @@ package org.apache.mahout.math.hadoop.si
 import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
+import java.io.Serializable;
 
 import org.apache.hadoop.io.WritableComparable;
 import org.apache.hadoop.io.WritableComparator;
@@ -85,7 +86,7 @@ public class SimilarityMatrixEntryKey im
     return other instanceof SimilarityMatrixEntryKey && row == ((SimilarityMatrixEntryKey) other).row;
   }
 
-  public static class SimilarityMatrixEntryKeyComparator extends WritableComparator {
+  public static class SimilarityMatrixEntryKeyComparator extends WritableComparator implements Serializable {
 
     protected SimilarityMatrixEntryKeyComparator() {
       super(SimilarityMatrixEntryKey.class, true);
@@ -112,7 +113,7 @@ public class SimilarityMatrixEntryKey im
     }
   }
 
-  public static class SimilarityMatrixEntryKeyGroupingComparator extends WritableComparator {
+  public static class SimilarityMatrixEntryKeyGroupingComparator extends WritableComparator implements Serializable {
 
     protected SimilarityMatrixEntryKeyGroupingComparator() {
       super(SimilarityMatrixEntryKey.class, true);

Modified: mahout/trunk/core/src/main/java/org/apache/mahout/vectors/Dictionary.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/vectors/Dictionary.java?rev=993365&r1=993364&r2=993365&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/vectors/Dictionary.java (original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/vectors/Dictionary.java Tue Sep  7 13:54:21 2010
@@ -27,7 +27,7 @@ import java.util.Map;
 * Assigns integer codes to strings as they appear.
 */
 public class Dictionary {
-  private Map<String, Integer> dict = Maps.newLinkedHashMap();
+  private final Map<String, Integer> dict = Maps.newLinkedHashMap();
 
   public int intern(String s) {
     if (!dict.containsKey(s)) {

Modified: mahout/trunk/core/src/main/java/org/apache/mahout/vectors/InteractionValueEncoder.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/vectors/InteractionValueEncoder.java?rev=993365&r1=993364&r2=993365&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/vectors/InteractionValueEncoder.java (original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/vectors/InteractionValueEncoder.java Tue Sep  7 13:54:21 2010
@@ -22,8 +22,8 @@ import org.apache.mahout.math.Vector;
 import java.util.Locale;
 
 public class InteractionValueEncoder extends FeatureVectorEncoder {
-  private FeatureVectorEncoder firstEncoder;
-  private FeatureVectorEncoder secondEncoder;
+  private final FeatureVectorEncoder firstEncoder;
+  private final FeatureVectorEncoder secondEncoder;
 
   public InteractionValueEncoder(String name, FeatureVectorEncoder encoderOne, FeatureVectorEncoder encoderTwo) {
     super(name, 2);

Modified: mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/hadoop/similarity/item/ItemSimilarityTest.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/hadoop/similarity/item/ItemSimilarityTest.java?rev=993365&r1=993364&r2=993365&view=diff
==============================================================================
--- mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/hadoop/similarity/item/ItemSimilarityTest.java (original)
+++ mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/hadoop/similarity/item/ItemSimilarityTest.java Tue Sep  7 13:54:21 2010
@@ -81,7 +81,7 @@ public final class ItemSimilarityTest ex
       public boolean matches(Object argument) {
         if (argument instanceof CountUsersKeyWritable) {
           CountUsersKeyWritable key = (CountUsersKeyWritable) argument;
-          return (userID == key.getUserID());
+          return userID == key.getUserID();
         }
         return false;
       }

Modified: mahout/trunk/core/src/test/java/org/apache/mahout/clustering/dirichlet/TestMapReduce.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/dirichlet/TestMapReduce.java?rev=993365&r1=993364&r2=993365&view=diff
==============================================================================
--- mahout/trunk/core/src/test/java/org/apache/mahout/clustering/dirichlet/TestMapReduce.java (original)
+++ mahout/trunk/core/src/test/java/org/apache/mahout/clustering/dirichlet/TestMapReduce.java Tue Sep  7 13:54:21 2010
@@ -16,7 +16,6 @@
  */
 package org.apache.mahout.clustering.dirichlet;
 
-import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;

Modified: mahout/trunk/core/src/test/java/org/apache/mahout/clustering/kmeans/TestKmeansClustering.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/kmeans/TestKmeansClustering.java?rev=993365&r1=993364&r2=993365&view=diff
==============================================================================
--- mahout/trunk/core/src/test/java/org/apache/mahout/clustering/kmeans/TestKmeansClustering.java (original)
+++ mahout/trunk/core/src/test/java/org/apache/mahout/clustering/kmeans/TestKmeansClustering.java Tue Sep  7 13:54:21 2010
@@ -17,7 +17,6 @@
 
 package org.apache.mahout.clustering.kmeans;
 
-import java.io.File;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;

Modified: mahout/trunk/core/src/test/java/org/apache/mahout/clustering/kmeans/TestRandomSeedGenerator.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/kmeans/TestRandomSeedGenerator.java?rev=993365&r1=993364&r2=993365&view=diff
==============================================================================
--- mahout/trunk/core/src/test/java/org/apache/mahout/clustering/kmeans/TestRandomSeedGenerator.java (original)
+++ mahout/trunk/core/src/test/java/org/apache/mahout/clustering/kmeans/TestRandomSeedGenerator.java Tue Sep  7 13:54:21 2010
@@ -17,12 +17,10 @@
 
 package org.apache.mahout.clustering.kmeans;
 
-import java.io.File;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.List;
-import java.util.Set;
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
@@ -79,7 +77,7 @@ public final class TestRandomSeedGenerat
     RandomSeedGenerator.buildRandom(input, output, 4, new ManhattanDistanceMeasure());
     
     SequenceFile.Reader reader = new SequenceFile.Reader(fs, new Path(output, "part-randomSeed"), conf);
-    Writable key = (Writable) reader.getKeyClass().newInstance();
+    Writable key = reader.getKeyClass().asSubclass(Writable.class).newInstance();
     AbstractCluster value = (AbstractCluster) reader.getValueClass().newInstance();
     
     int clusterCount = 0;

Modified: mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/PrepareTwentyNewsgroups.java
URL: http://svn.apache.org/viewvc/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/PrepareTwentyNewsgroups.java?rev=993365&r1=993364&r2=993365&view=diff
==============================================================================
--- mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/PrepareTwentyNewsgroups.java (original)
+++ mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/PrepareTwentyNewsgroups.java Tue Sep  7 13:54:21 2010
@@ -88,7 +88,7 @@ public final class PrepareTwentyNewsgrou
       Charset charset = Charset.forName((String) cmdLine.getValue(charsetOpt));
       Analyzer analyzer;
       try {
-        analyzer = (Analyzer) Class.forName(analyzerName).newInstance();
+        analyzer = Class.forName(analyzerName).asSubclass(Analyzer.class).newInstance();
       } catch (InstantiationException e) {
         analyzer = (Analyzer) Class.forName(analyzerName).getConstructor(Version.class).newInstance(Version.LUCENE_30);
       }

Modified: mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/SplitBayesInput.java
URL: http://svn.apache.org/viewvc/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/SplitBayesInput.java?rev=993365&r1=993364&r2=993365&view=diff
==============================================================================
--- mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/SplitBayesInput.java (original)
+++ mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/SplitBayesInput.java Tue Sep  7 13:54:21 2010
@@ -27,7 +27,6 @@ import java.io.OutputStreamWriter;
 import java.io.Writer;
 import java.nio.charset.Charset;
 import java.util.BitSet;
-import java.util.Date;
 
 import org.apache.commons.cli2.CommandLine;
 import org.apache.commons.cli2.Group;
@@ -41,7 +40,6 @@ import org.apache.mahout.common.CommandL
 import org.apache.mahout.common.IOUtils;
 import org.apache.mahout.common.RandomUtils;
 import org.apache.mahout.common.commandline.DefaultOptionCreator;
-import org.apache.mahout.math.jet.random.engine.MersenneTwister;
 import org.apache.mahout.math.jet.random.sampling.RandomSampler;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -206,8 +204,7 @@ public class SplitBayesInput {
 
       if (cmdLine.hasOption(testSplitSizeOpt) && cmdLine.hasOption(testSplitPctOpt)) {
         throw new OptionException(testSplitSizeOpt, "must have either split size or split percentage option, not BOTH");
-      }
-      else if (!cmdLine.hasOption(testSplitSizeOpt) && !cmdLine.hasOption(testSplitPctOpt)) {
+      } else if (!cmdLine.hasOption(testSplitSizeOpt) && !cmdLine.hasOption(testSplitPctOpt)) {
         throw new OptionException(testSplitSizeOpt, "must have either split size or split percentage option");
       }
 
@@ -298,18 +295,17 @@ public class SplitBayesInput {
       testSplitSize = this.testRandomSelectionSize;
       
       if (testRandomSelectionPct > 0) {
-        testSplitSize = Math.round(lineCount * ( testRandomSelectionPct / 100.0f ));
+        testSplitSize = Math.round(lineCount * (testRandomSelectionPct / 100.0f));
       }
       log.info("{} test split size is {} based on random selection percentage {}",
                new Object[] {inputFile.getName(), testSplitSize, testRandomSelectionPct});
       long[] ridx = new long[testSplitSize];
-      RandomSampler.sample(testSplitSize, lineCount-1, testSplitSize, 0, ridx, 0, RandomUtils.getRandom());
+      RandomSampler.sample(testSplitSize, lineCount - 1, testSplitSize, 0, ridx, 0, RandomUtils.getRandom());
       randomSel = new BitSet(lineCount);
       for (long idx : ridx) {
         randomSel.set((int) idx + 1);
       }
-    }
-    else {
+    } else {
       if (testSplitPct > 0) { // calculate split size based on percentage
         testSplitSize = Math.round(lineCount * (testSplitPct / 100.0f));
         log.info("{} test split size is {} based on percentage {}",
@@ -331,11 +327,10 @@ public class SplitBayesInput {
       if (testSplitStart < 0) {
         throw new IllegalArgumentException("test split size for " + inputFile + " is too large, it would produce an "
             + "empty training set from the initial set of " + lineCount + " examples");
-      }
-      else if ((lineCount - testSplitSize) < testSplitSize) {
+      } else if ((lineCount - testSplitSize) < testSplitSize) {
         log.warn("Test set size for {} may be too large, {} is larger than the number of "
                  + "lines remaining in the training set: {}",
-                 new Object[] {inputFile, testSplitSize, (lineCount - testSplitSize)});
+                 new Object[] {inputFile, testSplitSize, lineCount - testSplitSize});
       }
     }
     BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(inputFile), charset));
@@ -542,12 +537,11 @@ public class SplitBayesInput {
     }
 
     if (count == 0) {
-      throw new IllegalArgumentException("either test split size, test split pct, " +
-        "random selection size or random selection pct must be specified and a positive integer");
-    }
-    else if (count > 1) {
-      throw new IllegalArgumentException("only test split size, test split pct, " +
-        "random selection size or random selection pct may be specified");
+      throw new IllegalArgumentException("either test split size, test split pct, "
+          + "random selection size or random selection pct must be specified and a positive integer");
+    } else if (count > 1) {
+      throw new IllegalArgumentException("only test split size, test split pct, "
+          + "random selection size or random selection pct may be specified");
     }
 
     if (trainingOutputDirectory == null) {

Modified: mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/sgd/TrainLogistic.java
URL: http://svn.apache.org/viewvc/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/sgd/TrainLogistic.java?rev=993365&r1=993364&r2=993365&view=diff
==============================================================================
--- mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/sgd/TrainLogistic.java (original)
+++ mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/sgd/TrainLogistic.java Tue Sep  7 13:54:21 2010
@@ -29,10 +29,13 @@ import org.apache.commons.cli2.commandli
 import org.apache.commons.cli2.util.HelpFormatter;
 import org.apache.mahout.math.RandomAccessSparseVector;
 import org.apache.mahout.math.Vector;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
-import java.io.*;
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
 import java.net.URL;
 import java.util.List;
 
@@ -40,15 +43,17 @@ import java.util.List;
 /**
  * Train a logistic regression for the examples from Chapter 13 of Mahout in Action
  */
-public class TrainLogistic {
-  private static final Logger log = LoggerFactory.getLogger(TrainLogistic.class);
+public final class TrainLogistic {
+
   private static String inputFile;
   private static String outputFile;
   private static LogisticModelParameters lmp;
 
   private static int passes;
-  private static boolean scores = false;
+  private static boolean scores;
 
+  private TrainLogistic() {
+  }
 
   public static void main(String[] args) throws IOException {
     if (parseArgs(args)) {
@@ -92,9 +97,12 @@ public class TrainLogistic {
         in.close();
       }
 
-      FileWriter modelOutput = new FileWriter(outputFile);
-      lmp.saveTo(modelOutput);
-      modelOutput.close();
+      OutputStreamWriter modelOutput = new FileWriter(outputFile);
+      try {
+        lmp.saveTo(modelOutput);
+      } finally {
+        modelOutput.close();
+      }
       
       System.out.printf("%d\n", lmp.getNumFeatures());
       System.out.printf("%s ~ ", lmp.getTargetVariable());
@@ -278,6 +286,9 @@ public class TrainLogistic {
   }
 
   public static class InputOpener {
+    private InputOpener() {
+    }
+
     public static BufferedReader open(String inputFile) throws IOException {
       InputStreamReader s;
       try {

Modified: mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/display/DisplayClustering.java
URL: http://svn.apache.org/viewvc/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/display/DisplayClustering.java?rev=993365&r1=993364&r2=993365&view=diff
==============================================================================
--- mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/display/DisplayClustering.java (original)
+++ mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/display/DisplayClustering.java Tue Sep  7 13:54:21 2010
@@ -66,7 +66,7 @@ public class DisplayClustering extends F
   protected static final List<List<Cluster>> CLUSTERS = new ArrayList<List<Cluster>>();
 
   static final Color[] COLORS = {
-      Color.red, Color.orange, Color.yellow, Color.green, Color.blue, Color.magenta, Color.lightGray
+    Color.red, Color.orange, Color.yellow, Color.green, Color.blue, Color.magenta, Color.lightGray
   };
 
   protected static final double T1 = 3.0;
@@ -254,7 +254,7 @@ public class DisplayClustering extends F
       SequenceFile.Reader reader = new SequenceFile.Reader(fs, s.getPath(), conf);
       try {
         Writable key = new Text();
-        Writable value = (Writable) reader.getValueClass().newInstance();
+        Writable value = reader.getValueClass().asSubclass(Writable.class).newInstance();
         while (reader.next(key, value)) {
           Cluster cluster = (Cluster) value;
           log.info("Reading Cluster:{} center:{} numPoints:{} radius:{}", new Object[] {
@@ -264,7 +264,7 @@ public class DisplayClustering extends F
               AbstractCluster.formatVector(cluster.getRadius(), null)
           });
           clusters.add(cluster);
-          value = (Writable) reader.getValueClass().newInstance();
+          value = reader.getValueClass().asSubclass(Writable.class).newInstance();
         }
       } finally {
         reader.close();

Modified: mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/display/DisplayMeanShift.java
URL: http://svn.apache.org/viewvc/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/display/DisplayMeanShift.java?rev=993365&r1=993364&r2=993365&view=diff
==============================================================================
--- mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/display/DisplayMeanShift.java (original)
+++ mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/display/DisplayMeanShift.java Tue Sep  7 13:54:21 2010
@@ -115,8 +115,7 @@ final class DisplayMeanShift extends Dis
       for (VectorWritable sample : SAMPLE_DATA) {
         points.add(sample.get());
       }
-      List<MeanShiftCanopy> canopies = new ArrayList<MeanShiftCanopy>();
-      canopies = MeanShiftCanopyClusterer.clusterPoints(points, measure, 0.005, t1, t2, 20);
+      List<MeanShiftCanopy> canopies = MeanShiftCanopyClusterer.clusterPoints(points, measure, 0.005, t1, t2, 20);
       for (MeanShiftCanopy canopy : canopies) {
         log.info(canopy.toString());
       }

Modified: mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/fuzzykmeans/Job.java
URL: http://svn.apache.org/viewvc/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/fuzzykmeans/Job.java?rev=993365&r1=993364&r2=993365&view=diff
==============================================================================
--- mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/fuzzykmeans/Job.java (original)
+++ mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/fuzzykmeans/Job.java Tue Sep  7 13:54:21 2010
@@ -103,13 +103,16 @@ public final class Job extends FuzzyKMea
       HadoopUtil.overwriteOutput(output);
     }
     ClassLoader ccl = Thread.currentThread().getContextClassLoader();
-    DistanceMeasure measure = (DistanceMeasure) ((Class<?>) ccl.loadClass(measureClass)).newInstance();
+    DistanceMeasure measure = ccl.loadClass(measureClass).asSubclass(DistanceMeasure.class).newInstance();
 
     if (hasOption(DefaultOptionCreator.NUM_CLUSTERS_OPTION)) {
-      clusters = RandomSeedGenerator.buildRandom(input, clusters, Integer.parseInt(argMap
-          .get(DefaultOptionCreator.NUM_CLUSTERS_OPTION)), measure);
+      clusters = RandomSeedGenerator.buildRandom(
+          input,
+          clusters,
+          Integer.parseInt(argMap.get(DefaultOptionCreator.NUM_CLUSTERS_OPTION)),
+          measure);
     }
-    boolean runClustering = hasOption(DefaultOptionCreator.CLUSTERING_OPTION);
+    //boolean runClustering = hasOption(DefaultOptionCreator.CLUSTERING_OPTION);
     double t1 = Double.parseDouble(getOption(DefaultOptionCreator.T1_OPTION));
     double t2 = Double.parseDouble(getOption(DefaultOptionCreator.T2_OPTION));
     job(input, output, measure, t1, t2, maxIterations, numReduceTasks, fuzziness, convergenceDelta);

Modified: mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/meanshift/Job.java
URL: http://svn.apache.org/viewvc/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/meanshift/Job.java?rev=993365&r1=993364&r2=993365&view=diff
==============================================================================
--- mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/meanshift/Job.java (original)
+++ mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/meanshift/Job.java Tue Sep  7 13:54:21 2010
@@ -48,7 +48,7 @@ public final class Job extends MeanShift
       log.info("Running with default arguments");
       Path output = new Path("output");
       HadoopUtil.overwriteOutput(output);
-      new Job().job(new Path("testdata"), output, new EuclideanDistanceMeasure(), 47.6, 1, 0.5, 10);
+      job(new Path("testdata"), output, new EuclideanDistanceMeasure(), 47.6, 1, 0.5, 10);
     }
   }
 
@@ -114,14 +114,14 @@ public final class Job extends MeanShift
    * @param maxIterations
    *          the int maximum number of iterations
    */
-  private void job(Path input,
-                   Path output,
-                   DistanceMeasure measure,
-                   double t1,
-                   double t2,
-                   double convergenceDelta,
-                   int maxIterations) throws IOException, InterruptedException, ClassNotFoundException, InstantiationException,
-      IllegalAccessException {
+  private static void job(Path input,
+                          Path output,
+                          DistanceMeasure measure,
+                          double t1,
+                          double t2,
+                          double convergenceDelta,
+                          int maxIterations)
+    throws IOException, InterruptedException, ClassNotFoundException, InstantiationException, IllegalAccessException {
     Path directoryContainingConvertedInput = new Path(output, Constants.DIRECTORY_CONTAINING_CONVERTED_INPUT);
     InputDriver.runJob(input, directoryContainingConvertedInput);
     MeanShiftCanopyDriver.runJob(directoryContainingConvertedInput,
@@ -135,8 +135,8 @@ public final class Job extends MeanShift
                                  true,
                                  false);
     // run ClusterDumper
-    ClusterDumper clusterDumper = new ClusterDumper(new Path(output, "clusters-" + maxIterations), new Path(output,
-                                                                                                            "clusteredPoints"));
+    ClusterDumper clusterDumper =
+        new ClusterDumper(new Path(output, "clusters-" + maxIterations), new Path(output, "clusteredPoints"));
     clusterDumper.printClusters(null);
   }
 

Modified: mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/travellingsalesman/TravellingSalesman.java
URL: http://svn.apache.org/viewvc/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/travellingsalesman/TravellingSalesman.java?rev=993365&r1=993364&r2=993365&view=diff
==============================================================================
--- mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/travellingsalesman/TravellingSalesman.java (original)
+++ mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/travellingsalesman/TravellingSalesman.java Tue Sep  7 13:54:21 2010
@@ -121,7 +121,7 @@ public final class TravellingSalesman ex
     dialog.setVisible(true);
   }
 
-  private class TSSwingBackgroundTask extends SwingBackgroundTask<List<String>> {
+  private final class TSSwingBackgroundTask extends SwingBackgroundTask<List<String>> {
 
     private long elapsedTime;
     private final TravellingSalesmanStrategy strategy;

Modified: mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/Beta.java
URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/Beta.java?rev=993365&r1=993364&r2=993365&view=diff
==============================================================================
--- mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/Beta.java (original)
+++ mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/Beta.java Tue Sep  7 13:54:21 2010
@@ -8,8 +8,6 @@ It is provided "as is" without expressed
 */
 package org.apache.mahout.math.jet.random;
 
-import org.apache.mahout.common.RandomUtils;
-import org.apache.mahout.math.jet.random.engine.RandomEngine;
 import org.apache.mahout.math.jet.stat.Probability;
 
 import java.util.Random;
@@ -21,11 +19,11 @@ public class Beta extends AbstractContin
   private double alpha;
   private double beta;
 
-  private double PDF_CONST; // cache to speed up pdf()
+  private double pdfConst; // cache to speed up pdf()
 
   // cached values shared by bXX
-  private double aLast = 0.0;
-  private double bLast = 0.0;
+  private double aLast;
+  private double bLast;
   private double aMinus1;
   private double bMinus1;
   private double t;
@@ -41,8 +39,8 @@ public class Beta extends AbstractContin
   private double mu;
 
   // cached values for b1prs
-  private double pLast = 0.0;
-  private double qLast = 0.0;
+  private double pLast;
+  private double qLast;
   private double a;
   private double b;
   private double m;
@@ -124,12 +122,9 @@ public class Beta extends AbstractContin
         }
       }
     }
-    return (X);
+    return X;
   }
 
-  /**
-   *
-   */
   protected double b01(double a, double b, Random randomGenerator) {
 
     if (a != aLast || b != bLast) {
@@ -179,7 +174,7 @@ public class Beta extends AbstractContin
         X = 1.0 - (1.0 - t) * Z;
         // squeeze accept:   L(x) = 1 + (1 - a)(1 - x)
         V = randomGenerator.nextDouble() * fa;
-        if ((V) <= 1.0 - aMinus1 * (1.0 - X)) {
+        if (V <= 1.0 - aMinus1 * (1.0 - X)) {
           break;
         }
         // squeeze reject:   U(x) = 1 + (t^(a-1) - 1)/(1 - t) * (1 - x)
@@ -191,12 +186,9 @@ public class Beta extends AbstractContin
         }
       }
     }
-    return (X);
+    return X;
   }
 
-  /**
-   *
-   */
   protected double b1prs(double p, double q, Random randomGenerator) {
 
     if (p != pLast || q != qLast) {
@@ -212,7 +204,8 @@ public class Beta extends AbstractContin
       }
 
       if (a <= 1.0) {
-        x2 = (d1 = m * 0.5);
+        d1 = m * 0.5;
+        x2 = d1;
         x1 = z2 = 0.0;
         f1 = ll = 0.0;
       } else {
@@ -264,11 +257,11 @@ public class Beta extends AbstractContin
       if ((U = randomGenerator.nextDouble() * p4) <= p1) {
         // immediate accept:  x2 < X < m, - f(x2) < W < 0
         if ((W = U / d1 - f2) <= 0.0) {
-          return (m - U / f2);
+          return m - U / f2;
         }
         // immediate accept:  x1 < X < x2, 0 < W < f(x1)
         if (W <= f1) {
-          return (x2 - W / f1 * d1);
+          return x2 - W / f1 * d1;
         }
         // candidates for acceptance-rejection-test
         V = d1 * (U = randomGenerator.nextDouble());
@@ -276,27 +269,27 @@ public class Beta extends AbstractContin
         Y = x2 + V;
         // squeeze accept:    L(x) = f(x2) (x - z2) / (x2 - z2)
         if (W * (x2 - z2) <= f2 * (X - z2)) {
-          return (X);
+          return X;
         }
         if ((V = f2 + f2 - W) < 1.0) {
           // squeeze accept:    L(x) = f(x2) + (1 - f(x2))(x - x2)/(m - x2)
           if (V <= f2 + (1.0 - f2) * U) {
-            return (Y);
+            return Y;
           }
           // quotient accept:   x2 < Y < m,   W >= 2f2 - f(Y)
           if (V <= f(Y, a, b, m)) {
-            return (Y);
+            return Y;
           }
         }
       } else if (U <= p2) {
         U -= p1;
         // immediate accept:  m < X < x4, - f(x4) < W < 0
         if ((W = U / d - f4) <= 0.0) {
-          return (m + U / f4);
+          return m + U / f4;
         }
         // immediate accept:  x4 < X < x5, 0 < W < f(x5)
         if (W <= f5) {
-          return (x4 + W / f5 * d);
+          return x4 + W / f5 * d;
         }
         // candidates for acceptance-rejection-test
         V = d * (U = randomGenerator.nextDouble());
@@ -304,16 +297,16 @@ public class Beta extends AbstractContin
         Y = x4 - V;
         // squeeze accept:    L(x) = f(x4) (z4 - x) / (z4 - x4)
         if (W * (z4 - x4) <= f4 * (z4 - X)) {
-          return (X);
+          return X;
         }
         if ((V = f4 + f4 - W) < 1.0) {
           // squeeze accept:    L(x) = f(x4) + (1 - f(x4))(x4 - x)/(x4 - m)
           if (V <= f4 + (1.0 - f4) * U) {
-            return (Y);
+            return Y;
           }
           // quotient accept:   m < Y < x4,   W >= 2f4 - f(Y)
           if (V <= f(Y, a, b, m)) {
-            return (Y);
+            return Y;
           }
         }
       } else if (U <= p3) {                                     // X < x1
@@ -325,7 +318,7 @@ public class Beta extends AbstractContin
         // squeeze accept:    L(x) = f(x1) (x - z1) / (x1 - z1)
         //                    z1 = x1 - ll,   W <= 1 + (X - x1)/ll
         if (W <= 1.0 + Y) {
-          return (X);
+          return X;
         }
         W *= f1;
       } else {                                                  // x5 < X
@@ -337,18 +330,19 @@ public class Beta extends AbstractContin
         // squeeze accept:    L(x) = f(x5) (z5 - x) / (z5 - x5)
         //                    z5 = x5 + lr,   W <= 1 + (x5 - X)/lr
         if (W <= 1.0 + Y) {
-          return (X);
+          return X;
         }
         W *= f5;
       }
       // density accept:  f(x) = (x/m)^a ((1 - x)/(1 - m))^b
       if (Math.log(W) <= a * Math.log(X / m) + b * Math.log((1.0 - X) / (1.0 - m))) {
-        return (X);
+        return X;
       }
     }
   }
 
   /** Returns the cumulative distribution function. */
+  @Override
   public double cdf(double x) {
     return Probability.beta(alpha, beta, x);
   }
@@ -409,40 +403,41 @@ public class Beta extends AbstractContin
  ******************************************************************/
     if (alpha > 1.0) {
       if (beta > 1.0) {
-        return (b1prs(alpha, beta, randomGenerator));
+        return b1prs(alpha, beta, randomGenerator);
       }
       if (beta < 1.0) {
-        return (1.0 - b01(beta, alpha, randomGenerator));
+        return 1.0 - b01(beta, alpha, randomGenerator);
       }
-      return (Math.exp(Math.log(1 - randomGenerator.nextDouble()) / alpha));
+      return Math.exp(Math.log(1 - randomGenerator.nextDouble()) / alpha);
     }
 
     if (alpha < 1.0) {
       if (beta > 1.0) {
-        return (b01(alpha, beta, randomGenerator));
+        return b01(alpha, beta, randomGenerator);
       }
       if (beta < 1.0) {
-        return (b00(alpha, beta, randomGenerator));
+        return b00(alpha, beta, randomGenerator);
       }
-      return (Math.exp(Math.log(randomGenerator.nextDouble()) / alpha));
+      return Math.exp(Math.log(randomGenerator.nextDouble()) / alpha);
     }
 
     return beta == 1.0 ? randomGenerator.nextDouble() : 1.0 - Math.exp(Math.log(randomGenerator.nextDouble()) / beta);
   }
 
   /** Returns the cumulative distribution function. */
+  @Override
   public double pdf(double x) {
     if (x < 0 || x > 1) {
       return 0.0;
     }
-    return Math.exp(PDF_CONST) * Math.pow(x, alpha - 1) * Math.pow(1 - x, beta - 1);
+    return Math.exp(pdfConst) * Math.pow(x, alpha - 1) * Math.pow(1 - x, beta - 1);
   }
 
   /** Sets the parameters. */
   public final void setState(double alpha, double beta) {
     this.alpha = alpha;
     this.beta = beta;
-    this.PDF_CONST = Fun.logGamma(alpha + beta) - Fun.logGamma(alpha) - Fun.logGamma(beta);
+    this.pdfConst = Fun.logGamma(alpha + beta) - Fun.logGamma(alpha) - Fun.logGamma(beta);
   }
 
   /** Returns a String representation of the receiver. */

Modified: mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/BreitWigner.java
URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/BreitWigner.java?rev=993365&r1=993364&r2=993365&view=diff
==============================================================================
--- mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/BreitWigner.java (original)
+++ mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/BreitWigner.java Tue Sep  7 13:54:21 2010
@@ -9,7 +9,6 @@ It is provided "as is" without expressed
 package org.apache.mahout.math.jet.random;
 
 import org.apache.mahout.common.RandomUtils;
-import org.apache.mahout.math.jet.random.engine.RandomEngine;
 
 import java.util.Random;
 

Modified: mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/BreitWignerMeanSquare.java
URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/BreitWignerMeanSquare.java?rev=993365&r1=993364&r2=993365&view=diff
==============================================================================
--- mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/BreitWignerMeanSquare.java (original)
+++ mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/BreitWignerMeanSquare.java Tue Sep  7 13:54:21 2010
@@ -9,7 +9,6 @@ It is provided "as is" without expressed
 package org.apache.mahout.math.jet.random;
 
 import org.apache.mahout.common.RandomUtils;
-import org.apache.mahout.math.jet.random.engine.RandomEngine;
 
 import java.util.Random;
 

Modified: mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/ChiSquare.java
URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/ChiSquare.java?rev=993365&r1=993364&r2=993365&view=diff
==============================================================================
--- mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/ChiSquare.java (original)
+++ mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/ChiSquare.java Tue Sep  7 13:54:21 2010
@@ -9,7 +9,6 @@ It is provided "as is" without expressed
 package org.apache.mahout.math.jet.random;
 
 import org.apache.mahout.common.RandomUtils;
-import org.apache.mahout.math.jet.random.engine.RandomEngine;
 import org.apache.mahout.math.jet.stat.Probability;
 
 import java.util.Random;
@@ -18,17 +17,17 @@ import java.util.Random;
 @Deprecated
 public class ChiSquare extends AbstractContinousDistribution {
 
+  // The uniform random number generated shared by all <b>static</b> methods.
+  private static final ChiSquare SHARED = new ChiSquare(1.0, RandomUtils.getRandom());
+
   private double freedom;
 
   // cached vars for method nextDouble(a) (for performance only)
-  private double freedom_in = -1.0;
+  private double freedomIn = -1.0;
   private double b;
   private double vm;
   private double vd;
 
-  // The uniform random number generated shared by all <b>static</b> methods.
-  private static final ChiSquare shared = new ChiSquare(1.0, RandomUtils.getRandom());
-
   /**
    * Constructs a ChiSquare distribution. Example: freedom=1.0.
    *
@@ -41,6 +40,7 @@ public class ChiSquare extends AbstractC
   }
 
   /** Returns the cumulative distribution function. */
+  @Override
   public double cdf(double x) {
     return Probability.chiSquare(freedom, x);
   }
@@ -96,23 +96,23 @@ public class ChiSquare extends AbstractC
           r += zz * z / (3.0 * z);
         }
         if (u < r * 0.3894003915) {
-          return (z * z);
+          return z * z;
         }
         if (zz > (1.036961043 / u + 1.4)) {
           continue;
         }
         if (2.0 * Math.log(u) < (-zz * 0.5)) {
-          return (z * z);
+          return z * z;
         }
       }
     } else {
-      if (freedom != freedom_in) {
+      if (freedom != freedomIn) {
         b = Math.sqrt(freedom - 1.0);
         vm = -0.6065306597 * (1.0 - 0.25 / (b * b + 1.0));
         vm = (-b > vm) ? -b : vm;
         double vp = 0.6065306597 * (0.7071067812 + b) / (0.5 + b);
         vd = vp - vm;
-        freedom_in = freedom;
+        freedomIn = freedom;
       }
       while (true) {
         u = randomGenerator.nextDouble();
@@ -127,19 +127,20 @@ public class ChiSquare extends AbstractC
           r += zz * z / (3.0 * (z + b));
         }
         if (u < r * 0.3894003915) {
-          return ((z + b) * (z + b));
+          return (z + b) * (z + b);
         }
         if (zz > (1.036961043 / u + 1.4)) {
           continue;
         }
         if (2.0 * Math.log(u) < (Math.log(1.0 + z / b) * b * b - zz * 0.5 - z * b)) {
-          return ((z + b) * (z + b));
+          return (z + b) * (z + b);
         }
       }
     }
   }
 
   /** Returns the probability distribution function. */
+  @Override
   public double pdf(double x) {
     if (x <= 0.0) {
       throw new IllegalArgumentException();
@@ -168,8 +169,8 @@ public class ChiSquare extends AbstractC
    * @throws IllegalArgumentException if <tt>freedom &lt; 1.0</tt>.
    */
   public static double staticNextDouble(double freedom) {
-    synchronized (shared) {
-      return shared.nextDouble(freedom);
+    synchronized (SHARED) {
+      return SHARED.nextDouble(freedom);
     }
   }
 

Modified: mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/Empirical.java
URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/Empirical.java?rev=993365&r1=993364&r2=993365&view=diff
==============================================================================
--- mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/Empirical.java (original)
+++ mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/Empirical.java Tue Sep  7 13:54:21 2010
@@ -8,8 +8,6 @@ It is provided "as is" without expressed
 */
 package org.apache.mahout.math.jet.random;
 
-import org.apache.mahout.math.jet.random.engine.RandomEngine;
-
 import java.util.Random;
 
 /** @deprecated until unit tests are in place.  Until this time, this class/interface is unsupported. */

Modified: mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/EmpiricalWalker.java
URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/EmpiricalWalker.java?rev=993365&r1=993364&r2=993365&view=diff
==============================================================================
--- mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/EmpiricalWalker.java (original)
+++ mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/EmpiricalWalker.java Tue Sep  7 13:54:21 2010
@@ -8,8 +8,6 @@ It is provided "as is" without expressed
 */
 package org.apache.mahout.math.jet.random;
 
-import org.apache.mahout.math.jet.random.engine.RandomEngine;
-
 import java.util.Random;
 
 /** @deprecated until unit tests are in place.  Until this time, this class/interface is unsupported. */
@@ -134,7 +132,8 @@ public class EmpiricalWalker extends Abs
    * 0&lt;=i&lt;=pdf.length-1</tt> <li><tt>0.0 &lt; Sum(pdf[i]) : 0&lt;=i&lt;=pdf.length-1</tt> </ul>
    *
    * @param pdf               the probability distribution function.
-   * @param interpolationType can be either <tt>Empirical.NO_INTERPOLATION</tt> or <tt>Empirical.LINEAR_INTERPOLATION</tt>.
+   * @param interpolationType can be either
+   *  <tt>Empirical.NO_INTERPOLATION</tt> or <tt>Empirical.LINEAR_INTERPOLATION</tt>.
    * @param randomGenerator   a uniform random number generator.
    * @throws IllegalArgumentException if at least one of the three conditions above is violated.
    */
@@ -280,26 +279,26 @@ public class EmpiricalWalker extends Abs
         ++nBigs;
       }
     }
-    Stack Bigs = new Stack(nBigs);
-    Stack Smalls = new Stack(nSmalls);
+    Stack bigs = new Stack(nBigs);
+    Stack smalls = new Stack(nSmalls);
     for (k = 0; k < size; ++k) {
       if (E[k] < mean) {
-        Smalls.push(k);
+        smalls.push(k);
       } else {
-        Bigs.push(k);
+        bigs.push(k);
       }
     }
     /* Now work through the smalls */
     int b;
-    while (Smalls.size() > 0) {
-      int s = Smalls.pop();
-      if (Bigs.size() == 0) {
+    while (smalls.size() > 0) {
+      int s = smalls.pop();
+      if (bigs.size() == 0) {
         /* Then we are on our last value */
         this.A[s] = s;
         this.F[s] = 1.0;
         break;
       }
-      b = Bigs.pop();
+      b = bigs.pop();
       this.A[s] = b;
       this.F[s] = size * E[s];
 
@@ -307,17 +306,17 @@ public class EmpiricalWalker extends Abs
       E[s] += d;              /* now E[s] == mean */
       E[b] -= d;
       if (E[b] < mean) {
-        Smalls.push(b); /* no longer big, join ranks of the small */
+        smalls.push(b); /* no longer big, join ranks of the small */
       } else if (E[b] > mean) {
-        Bigs.push(b); /* still big, put it back where you found it */
+        bigs.push(b); /* still big, put it back where you found it */
       } else {
         /* E[b]==mean implies it is finished too */
         this.A[b] = b;
         this.F[b] = 1.0;
       }
     }
-    while (Bigs.size() > 0) {
-      b = Bigs.pop();
+    while (bigs.size() > 0) {
+      b = bigs.pop();
       this.A[b] = b;
       this.F[b] = 1.0;
     }

Modified: mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/Exponential.java
URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/Exponential.java?rev=993365&r1=993364&r2=993365&view=diff
==============================================================================
--- mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/Exponential.java (original)
+++ mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/Exponential.java Tue Sep  7 13:54:21 2010
@@ -8,8 +8,6 @@ It is provided "as is" without expressed
 */
 package org.apache.mahout.math.jet.random;
 
-import org.apache.mahout.math.jet.random.engine.RandomEngine;
-
 import java.util.Locale;
 import java.util.Random;
 

Modified: mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/ExponentialPower.java
URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/ExponentialPower.java?rev=993365&r1=993364&r2=993365&view=diff
==============================================================================
--- mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/ExponentialPower.java (original)
+++ mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/ExponentialPower.java Tue Sep  7 13:54:21 2010
@@ -9,7 +9,6 @@ It is provided "as is" without expressed
 package org.apache.mahout.math.jet.random;
 
 import org.apache.mahout.common.RandomUtils;
-import org.apache.mahout.math.jet.random.engine.RandomEngine;
 
 import java.util.Random;
 
@@ -17,15 +16,15 @@ import java.util.Random;
 @Deprecated
 public class ExponentialPower extends AbstractContinousDistribution {
 
+  // The uniform random number generated shared by all <b>static</b> methods.
+  private static final ExponentialPower SHARED = new ExponentialPower(1.0, RandomUtils.getRandom());
+
   private double tau;
 
   // cached vars for method nextDouble(tau) (for performance only)
   private double s;
   private double sm1;
-  private double tau_set = -1.0;
-
-  // The uniform random number generated shared by all <b>static</b> methods.
-  private static final ExponentialPower shared = new ExponentialPower(1.0, RandomUtils.getRandom());
+  private double tauSet = -1.0;
 
   /**
    * Constructs an Exponential Power distribution. Example: tau=1.0.
@@ -50,11 +49,11 @@ public class ExponentialPower extends Ab
    */
   public double nextDouble(double tau) {
 
-    if (tau != tau_set) { // SET-UP
+    if (tau != tauSet) { // SET-UP
       s = 1.0 / tau;
       sm1 = 1.0 - s;
 
-      tau_set = tau;
+      tauSet = tau;
     }
 
     // GENERATOR
@@ -101,8 +100,8 @@ public class ExponentialPower extends Ab
    * @throws IllegalArgumentException if <tt>tau &lt; 1.0</tt>.
    */
   public static double staticNextDouble(double tau) {
-    synchronized (shared) {
-      return shared.nextDouble(tau);
+    synchronized (SHARED) {
+      return SHARED.nextDouble(tau);
     }
   }
 

Modified: mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/Gamma.java
URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/Gamma.java?rev=993365&r1=993364&r2=993365&view=diff
==============================================================================
--- mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/Gamma.java (original)
+++ mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/Gamma.java Tue Sep  7 13:54:21 2010
@@ -25,7 +25,6 @@ It is provided "as is" without expressed
 */
 package org.apache.mahout.math.jet.random;
 
-import org.apache.mahout.math.jet.random.engine.RandomEngine;
 import org.apache.mahout.math.jet.stat.Probability;
 
 import java.util.Random;

Modified: mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/HyperGeometric.java
URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/HyperGeometric.java?rev=993365&r1=993364&r2=993365&view=diff
==============================================================================
--- mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/HyperGeometric.java (original)
+++ mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/HyperGeometric.java Tue Sep  7 13:54:21 2010
@@ -10,7 +10,6 @@ package org.apache.mahout.math.jet.rando
 
 import org.apache.mahout.common.RandomUtils;
 import org.apache.mahout.math.jet.math.Arithmetic;
-import org.apache.mahout.math.jet.random.engine.RandomEngine;
 
 import java.util.Random;
 
@@ -18,15 +17,18 @@ import java.util.Random;
 @Deprecated
 public class HyperGeometric extends AbstractDiscreteDistribution {
 
-  private int my_N;
-  private int my_s;
-  private int my_n;
+  // The uniform random number generated shared by all <b>static</b> methods.
+  private static final HyperGeometric SHARED = new HyperGeometric(1, 1, 1, RandomUtils.getRandom());
+
+  private int myN;
+  private int myS;
+  private int myn;
 
   // cached vars shared by hmdu(...) and hprs(...)
-  private int N_last = -1;
-  private int M_last = -1;
-  private int n_last = -1;
-  private int N_Mn;
+  private int NLast = -1;
+  private int MLast = -1;
+  private int nLast = -1;
+  private int NMn;
   private int m;
 
   // cached vars for hmdu(...)
@@ -49,7 +51,7 @@ public class HyperGeometric extends Abst
   private double r5;
   private double ll;
   private double lr;
-  private double c_pm;
+  private double cpm;
   private double f1;
   private double f2;
   private double f4;
@@ -61,32 +63,30 @@ public class HyperGeometric extends Abst
   private double p5;
   private double p6;
 
-
-  // The uniform random number generated shared by all <b>static</b> methods.
-  private static final HyperGeometric shared = new HyperGeometric(1, 1, 1, RandomUtils.getRandom());
-
   /** Constructs a HyperGeometric distribution. */
   public HyperGeometric(int N, int s, int n, Random randomGenerator) {
     setRandomGenerator(randomGenerator);
     setState(N, s, n);
   }
 
-  private static double fc_lnpk(int k, int N_Mn, int M, int n) {
-    return (Arithmetic.logFactorial(k) + Arithmetic.logFactorial(M - k) + Arithmetic.logFactorial(n - k) +
-        Arithmetic.logFactorial(N_Mn + k));
+  private static double fcLnpk(int k, int N_Mn, int M, int n) {
+    return Arithmetic.logFactorial(k)
+        + Arithmetic.logFactorial(M - k)
+        + Arithmetic.logFactorial(n - k)
+        + Arithmetic.logFactorial(N_Mn + k);
   }
 
   /** Returns a random number from the distribution. */
   protected int hmdu(int N, int M, int n, Random randomGenerator) {
 
-    if (N != N_last || M != M_last || n != n_last) {   // set-up           */
-      N_last = N;
-      M_last = M;
-      n_last = n;
+    if (N != NLast || M != MLast || n != nLast) {   // set-up           */
+      NLast = N;
+      MLast = M;
+      nLast = n;
 
       Mp = (double) (M + 1);
       np = (double) (n + 1);
-      N_Mn = N - M - n;
+      NMn = N - M - n;
 
       double p = Mp / (N + 2.0);
       double nu = np * p;
@@ -97,7 +97,7 @@ public class HyperGeometric extends Abst
       }
 
       /* mode probability, using the external function flogfak(k) = ln(k!)    */
-      fm = Math.exp(Arithmetic.logFactorial(N - M) - Arithmetic.logFactorial(N_Mn + m) - Arithmetic.logFactorial(n - m)
+      fm = Math.exp(Arithmetic.logFactorial(N - M) - Arithmetic.logFactorial(NMn + m) - Arithmetic.logFactorial(n - m)
           + Arithmetic.logFactorial(M) - Arithmetic.logFactorial(M - m) - Arithmetic.logFactorial(m)
           - Arithmetic.logFactorial(N) + Arithmetic.logFactorial(N - n) + Arithmetic.logFactorial(n));
 
@@ -112,7 +112,7 @@ public class HyperGeometric extends Abst
     while (true) {
       double U;
       if ((U = randomGenerator.nextDouble() - fm) <= 0.0) {
-        return (m);
+        return m;
       }
       double d;
       double c = d = fm;
@@ -121,13 +121,13 @@ public class HyperGeometric extends Abst
       int K;
       for (int I = 1; I <= m; I++) {
         K = mp - I;                                   /* downward search  */
-        c *= (double) K / (np - K) * ((double) (N_Mn + K) / (Mp - K));
+        c *= (double) K / (np - K) * ((double) (NMn + K) / (Mp - K));
         if ((U -= c) <= 0.0) {
           return (K - 1);
         }
 
         K = m + I;                                    /* upward search    */
-        d *= (np - K) / (double) K * ((Mp - K) / (double) (N_Mn + K));
+        d *= (np - K) / (double) K * ((Mp - K) / (double) (NMn + K));
         if ((U -= d) <= 0.0) {
           return (K);
         }
@@ -135,7 +135,7 @@ public class HyperGeometric extends Abst
 
       /* upward search from K = 2m + 1 to K = b                               */
       for (K = mp + m; K <= b; K++) {
-        d *= (np - K) / (double) K * ((Mp - K) / (double) (N_Mn + K));
+        d *= (np - K) / (double) K * ((Mp - K) / (double) (NMn + K));
         if ((U -= d) <= 0.0) {
           return (K);
         }
@@ -147,14 +147,14 @@ public class HyperGeometric extends Abst
   protected int hprs(int N, int M, int n, Random randomGenerator) {
     double U;         /* (X, Y) <-> (V, W) */
 
-    if (N != N_last || M != M_last || n != n_last) {  /* set-up            */
-      N_last = N;
-      M_last = M;
-      n_last = n;
+    if (N != NLast || M != MLast || n != nLast) {  /* set-up            */
+      NLast = N;
+      MLast = M;
+      nLast = n;
 
       double Mp = (double) (M + 1);
       double np = (double) (n + 1);
-      N_Mn = N - M - n;
+      NMn = N - M - n;
 
       double p = Mp / (N + 2.0);
       double nu = np * p;
@@ -181,23 +181,23 @@ public class HyperGeometric extends Abst
       dr = (double) (k5 - k4);
 
       // recurrence constants r(k) = p(k)/p(k-1) at k = k1, k2, k4+1, k5+1
-      r1 = (np / (double) k1 - 1.0) * (Mp - k1) / (double) (N_Mn + k1);
-      r2 = (np / (double) k2 - 1.0) * (Mp - k2) / (double) (N_Mn + k2);
-      r4 = (np / (double) (k4 + 1) - 1.0) * (M - k4) / (double) (N_Mn + k4 + 1);
-      r5 = (np / (double) (k5 + 1) - 1.0) * (M - k5) / (double) (N_Mn + k5 + 1);
+      r1 = (np / (double) k1 - 1.0) * (Mp - k1) / (double) (NMn + k1);
+      r2 = (np / (double) k2 - 1.0) * (Mp - k2) / (double) (NMn + k2);
+      r4 = (np / (double) (k4 + 1) - 1.0) * (M - k4) / (double) (NMn + k4 + 1);
+      r5 = (np / (double) (k5 + 1) - 1.0) * (M - k5) / (double) (NMn + k5 + 1);
 
       // reciprocal values of the scale parameters of expon. tail envelopes
       ll = Math.log(r1);                                  // expon. tail left  //
       lr = -Math.log(r5);                                  // expon. tail right //
 
       // hypergeom. constant, necessary for computing function values f(k)
-      c_pm = fc_lnpk(m, N_Mn, M, n);
+      cpm = fcLnpk(m, NMn, M, n);
 
       // function values f(k) = p(k)/p(m)  at  k = k2, k4, k1, k5
-      f2 = Math.exp(c_pm - fc_lnpk(k2, N_Mn, M, n));
-      f4 = Math.exp(c_pm - fc_lnpk(k4, N_Mn, M, n));
-      f1 = Math.exp(c_pm - fc_lnpk(k1, N_Mn, M, n));
-      f5 = Math.exp(c_pm - fc_lnpk(k5, N_Mn, M, n));
+      f2 = Math.exp(cpm - fcLnpk(k2, NMn, M, n));
+      f4 = Math.exp(cpm - fcLnpk(k4, NMn, M, n));
+      f1 = Math.exp(cpm - fcLnpk(k1, NMn, M, n));
+      f5 = Math.exp(cpm - fcLnpk(k5, NMn, M, n));
 
       // area of the two centre and the two exponential tail regions
       // area of the two immediate acceptance regions between k2, k4
@@ -221,26 +221,26 @@ public class HyperGeometric extends Abst
 
         // immediate acceptance region R2 = [k2, m) *[0, f2),  X = k2, ... m -1
         if ((W = U - p1) < 0.0) {
-          return (k2 + (int) (U / f2));
+          return k2 + (int) (U / f2);
         }
         // immediate acceptance region R1 = [k1, k2)*[0, f1),  X = k1, ... k2-1
         if ((Y = W / dl) < f1) {
-          return (k1 + (int) (W / f1));
+          return k1 + (int) (W / f1);
         }
 
         // computation of candidate X < k2, and its counterpart V > k2
         // either squeeze-acceptance of X or acceptance-rejection of V
-        Dk = (int) (dl * randomGenerator.nextDouble()) + 1;
+        Dk = randomGenerator.nextInt((int) dl) + 1;
         if (Y <= f2 - Dk * (f2 - f2 / r2)) {            // quick accept of
-          return (k2 - Dk);                          // X = k2 - Dk
+          return k2 - Dk;                          // X = k2 - Dk
         }
         if ((W = f2 + f2 - Y) < 1.0) {                // quick reject of V
           V = k2 + Dk;
           if (W <= f2 + Dk * (1.0 - f2) / (dl + 1.0)) { // quick accept of
-            return (V);                              // V = k2 + Dk
+            return V;                              // V = k2 + Dk
           }
-          if (Math.log(W) <= c_pm - fc_lnpk(V, N_Mn, M, n)) {
-            return (V);               // final accept of V
+          if (Math.log(W) <= cpm - fcLnpk(V, NMn, M, n)) {
+            return V;               // final accept of V
           }
         }
         X = k2 - Dk;
@@ -248,26 +248,26 @@ public class HyperGeometric extends Abst
 
         // immediate acceptance region R3 = [m, k4+1)*[0, f4), X = m, ... k4
         if ((W = U - p3) < 0.0) {
-          return (k4 - (int) ((U - p2) / f4));
+          return k4 - (int) ((U - p2) / f4);
         }
         // immediate acceptance region R4 = [k4+1, k5+1)*[0, f5)
         if ((Y = W / dr) < f5) {
-          return (k5 - (int) (W / f5));
+          return k5 - (int) (W / f5);
         }
 
         // computation of candidate X > k4, and its counterpart V < k4
         // either squeeze-acceptance of X or acceptance-rejection of V
-        Dk = (int) (dr * randomGenerator.nextDouble()) + 1;
+        Dk = randomGenerator.nextInt((int) dr) + 1;
         if (Y <= f4 - Dk * (f4 - f4 * r4)) {            // quick accept of
-          return (k4 + Dk);                          // X = k4 + Dk
+          return k4 + Dk;                          // X = k4 + Dk
         }
         if ((W = f4 + f4 - Y) < 1.0) {                // quick reject of V
           V = k4 - Dk;
           if (W <= f4 + Dk * (1.0 - f4) / dr) {       // quick accept of
-            return (V);                            // V = k4 - Dk
+            return V;                            // V = k4 - Dk
           }
-          if (Math.log(W) <= c_pm - fc_lnpk(V, N_Mn, M, n)) {
-            return (V);                            // final accept of V
+          if (Math.log(W) <= cpm - fcLnpk(V, NMn, M, n)) {
+            return V;                            // final accept of V
           }
         }
         X = k4 + Dk;
@@ -280,7 +280,7 @@ public class HyperGeometric extends Abst
           }         // 0 <= X <= k1 - 1
           Y *= (U - p4) * ll;                       // Y -- U(0, h(x))
           if (Y <= f1 - Dk * (f1 - f1 / r1)) {
-            return (X);                            // quick accept of X
+            return X;                            // quick accept of X
           }
         } else {                                        // expon. tail right
           Dk = (int) (1.0 - Math.log(Y) / lr);
@@ -289,7 +289,7 @@ public class HyperGeometric extends Abst
           }        // k5 + 1 <= X <= n
           Y *= (U - p5) * lr;                       // Y -- U(0, h(x))   /
           if (Y <= f5 - Dk * (f5 - f5 * r5)) {
-            return (X);                            // quick accept of X
+            return X;                            // quick accept of X
           }
         }
       }
@@ -299,8 +299,8 @@ public class HyperGeometric extends Abst
       // log f(X) = log( m! (M - m)! (n - m)! (N - M - n + m)! )
       //          - log( X! (M - X)! (n - X)! (N - M - n + X)! )
       // by using an external function for log k!
-      if (Math.log(Y) <= c_pm - fc_lnpk(X, N_Mn, M, n)) {
-        return (X);
+      if (Math.log(Y) <= cpm - fcLnpk(X, NMn, M, n)) {
+        return X;
       }
     }
   }
@@ -312,7 +312,7 @@ public class HyperGeometric extends Abst
    */
   @Override
   public int nextInt() {
-    return nextInt(this.my_N, this.my_s, this.my_n, this.randomGenerator);
+    return nextInt(this.myN, this.myS, this.myn, this.randomGenerator);
   }
 
   /** Returns a random number from the distribution; bypasses the internal state. */
@@ -366,18 +366,18 @@ public class HyperGeometric extends Abst
  ******************************************************************/
 
     int Nhalf = N / 2;
-    int n_le_Nhalf = (n <= Nhalf) ? n : N - n;
-    int M_le_Nhalf = (M <= Nhalf) ? M : N - M;
+    int nLeNhalf = (n <= Nhalf) ? n : N - n;
+    int mLeNhalf = (M <= Nhalf) ? M : N - M;
 
     int K;
     if ((n * M / N) < 10) {
-      K = (n_le_Nhalf <= M_le_Nhalf)
-          ? hmdu(N, M_le_Nhalf, n_le_Nhalf, randomGenerator)
-          : hmdu(N, n_le_Nhalf, M_le_Nhalf, randomGenerator);
+      K = (nLeNhalf <= mLeNhalf)
+          ? hmdu(N, mLeNhalf, nLeNhalf, randomGenerator)
+          : hmdu(N, nLeNhalf, mLeNhalf, randomGenerator);
     } else {
-      K = (n_le_Nhalf <= M_le_Nhalf)
-          ? hprs(N, M_le_Nhalf, n_le_Nhalf, randomGenerator)
-          : hprs(N, n_le_Nhalf, M_le_Nhalf, randomGenerator);
+      K = (nLeNhalf <= mLeNhalf)
+          ? hprs(N, mLeNhalf, nLeNhalf, randomGenerator)
+          : hprs(N, nLeNhalf, mLeNhalf, randomGenerator);
     }
 
     if (n <= Nhalf) {
@@ -389,27 +389,27 @@ public class HyperGeometric extends Abst
 
   /** Returns the probability distribution function. */
   public double pdf(int k) {
-    return Arithmetic.binomial(my_s, k) * Arithmetic.binomial(my_N - my_s, my_n - k)
-        / Arithmetic.binomial(my_N, my_n);
+    return Arithmetic.binomial(myS, k) * Arithmetic.binomial(myN - myS, myn - k)
+        / Arithmetic.binomial(myN, myn);  
   }
 
   /** Sets the parameters. */
   public void setState(int N, int s, int n) {
-    this.my_N = N;
-    this.my_s = s;
-    this.my_n = n;
+    this.myN = N;
+    this.myS = s;
+    this.myn = n;
   }
 
   /** Returns a random number from the distribution. */
   public static double staticNextInt(int N, int M, int n) {
-    synchronized (shared) {
-      return shared.nextInt(N, M, n);
+    synchronized (SHARED) {
+      return SHARED.nextInt(N, M, n);
     }
   }
 
   /** Returns a String representation of the receiver. */
   public String toString() {
-    return this.getClass().getName() + '(' + my_N + ',' + my_s + ',' + my_n + ')';
+    return this.getClass().getName() + '(' + myN + ',' + myS + ',' + myn + ')';
   }
 
 }

Modified: mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/Hyperbolic.java
URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/Hyperbolic.java?rev=993365&r1=993364&r2=993365&view=diff
==============================================================================
--- mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/Hyperbolic.java (original)
+++ mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/Hyperbolic.java Tue Sep  7 13:54:21 2010
@@ -9,7 +9,6 @@ It is provided "as is" without expressed
 package org.apache.mahout.math.jet.random;
 
 import org.apache.mahout.common.RandomUtils;
-import org.apache.mahout.math.jet.random.engine.RandomEngine;
 
 import java.util.Random;
 
@@ -17,12 +16,15 @@ import java.util.Random;
 @Deprecated
 public class Hyperbolic extends AbstractContinousDistribution {
 
+  // The uniform random number generated shared by all <b>static</b> methods.
+  private static final Hyperbolic SHARED = new Hyperbolic(10.0, 10.0, RandomUtils.getRandom());
+
   private double alpha;
   private double beta;
 
   // cached values shared for generateHyperbolic(...)
-  private double a_setup = 0.0;
-  private double b_setup = -1.0;
+  private double aSetup;
+  private double bSetup = -1.0;
   private double hr;
   private double hl;
   private double s;
@@ -30,12 +32,8 @@ public class Hyperbolic extends Abstract
   private double pr;
   private double samb;
   private double pmr;
-  private double mpa_1;
-  private double mmb_1;
-
-
-  // The uniform random number generated shared by all <b>static</b> methods.
-  private static final Hyperbolic shared = new Hyperbolic(10.0, 10.0, RandomUtils.getRandom());
+  private double mpa1;
+  private double mmb1;
 
   /** Constructs a Beta distribution. */
   public Hyperbolic(double alpha, double beta, Random randomGenerator) {
@@ -69,31 +67,31 @@ public class Hyperbolic extends Abstract
  *                                                                *
  ******************************************************************/
 
-    if ((a_setup != alpha) || (b_setup != beta)) { // SET-UP
+    if (aSetup != alpha || bSetup != beta) { // SET-UP
       //double pl;
       double amb = alpha * alpha - beta * beta;
       samb = Math.sqrt(amb);                                  // -log(f(mode))
       double mode = beta / samb;
-      double help_1 = alpha * Math.sqrt(2.0 * samb + 1.0);
-      double help_2 = beta * (samb + 1.0);
-      double mpa = (help_2 + help_1) / amb;
-      double mmb = (help_2 - help_1) / amb;
-      double a_ = mpa - mode;
-      double b_ = -mmb + mode;
+      double help1 = alpha * Math.sqrt(2.0 * samb + 1.0);
+      double help2 = beta * (samb + 1.0);
+      double mpa = (help2 + help1) / amb;
+      double mmb = (help2 - help1) / amb;
+      double a = mpa - mode;
+      double b = -mmb + mode;
       hr = -1.0 / (-alpha * mpa / Math.sqrt(1.0 + mpa * mpa) + beta);
       hl = 1.0 / (-alpha * mmb / Math.sqrt(1.0 + mmb * mmb) + beta);
-      double a_1 = a_ - hr;
-      double b_1 = b_ - hl;
-      mmb_1 = mode - b_1;                                     // lower border
-      mpa_1 = mode + a_1;                                     // upper border
+      double a1 = a - hr;
+      double b1 = b - hl;
+      mmb1 = mode - b1;                                     // lower border
+      mpa1 = mode + a1;                                     // upper border
 
-      s = (a_ + b_);
-      pm = (a_1 + b_1) / s;
+      s = a + b;
+      pm = (a1 + b1) / s;
       pr = hr / s;
       pmr = pm + pr;
 
-      a_setup = alpha;
-      b_setup = beta;
+      aSetup = alpha;
+      bSetup = beta;
     }
 
     // GENERATOR
@@ -103,7 +101,7 @@ public class Hyperbolic extends Abstract
       double v = randomGenerator.nextDouble();
       if (u <= pm) { // Rejection with a uniform majorizing function
         // over the body of the distribution
-        x = mmb_1 + u * s;
+        x = mmb1 + u * s;
         if (Math.log(v) <= (-alpha * Math.sqrt(1.0 + x * x) + beta * x + samb)) {
           break;
         }
@@ -112,14 +110,14 @@ public class Hyperbolic extends Abstract
         if (u <= pmr) {  // Rejection with an exponential envelope on the
           // right side of the mode
           e = -Math.log((u - pm) / pr);
-          x = mpa_1 + hr * e;
+          x = mpa1 + hr * e;
           if ((Math.log(v) - e) <= (-alpha * Math.sqrt(1.0 + x * x) + beta * x + samb)) {
             break;
           }
         } else {           // Rejection with an exponential envelope on the
           // left side of the mode
           e = Math.log((u - pmr) / (1.0 - pmr));
-          x = mmb_1 + hl * e;
+          x = mmb1 + hl * e;
           if ((Math.log(v) + e) <= (-alpha * Math.sqrt(1.0 + x * x) + beta * x + samb)) {
             break;
           }
@@ -127,7 +125,7 @@ public class Hyperbolic extends Abstract
       }
     }
 
-    return (x);
+    return x;
   }
 
   /** Sets the parameters. */
@@ -138,8 +136,8 @@ public class Hyperbolic extends Abstract
 
   /** Returns a random number from the distribution. */
   public static double staticNextDouble(double alpha, double beta) {
-    synchronized (shared) {
-      return shared.nextDouble(alpha, beta);
+    synchronized (SHARED) {
+      return SHARED.nextDouble(alpha, beta);
     }
   }
 

Modified: mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/Logarithmic.java
URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/Logarithmic.java?rev=993365&r1=993364&r2=993365&view=diff
==============================================================================
--- mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/Logarithmic.java (original)
+++ mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/Logarithmic.java Tue Sep  7 13:54:21 2010
@@ -9,7 +9,6 @@ It is provided "as is" without expressed
 package org.apache.mahout.math.jet.random;
 
 import org.apache.mahout.common.RandomUtils;
-import org.apache.mahout.math.jet.random.engine.RandomEngine;
 
 import java.util.Random;
 
@@ -17,15 +16,15 @@ import java.util.Random;
 @Deprecated
 public class Logarithmic extends AbstractContinousDistribution {
 
-  private double my_p;
+  // The uniform random number generated shared by all <b>static</b> methods.
+  private static final Logarithmic SHARED = new Logarithmic(0.5, RandomUtils.getRandom());
+
+  private double myP;
 
   // cached vars for method nextDouble(a) (for performance only)
   private double t;
   private double h;
-  private double a_prev = -1.0;
-
-  // The uniform random number generated shared by all <b>static</b> methods.
-  private static final Logarithmic shared = new Logarithmic(0.5, RandomUtils.getRandom());
+  private double aPrev = -1.0;
 
   /** Constructs a Logarithmic distribution. */
   public Logarithmic(double p, Random randomGenerator) {
@@ -36,7 +35,7 @@ public class Logarithmic extends Abstrac
   /** Returns a random number from the distribution. */
   @Override
   public double nextDouble() {
-    return nextDouble(this.my_p);
+    return nextDouble(this.myP);
   }
 
   /** Returns a random number from the distribution; bypasses the internal state. */
@@ -75,8 +74,8 @@ public class Logarithmic extends Abstrac
  *                                                                *
  ******************************************************************/
 
-    if (a != a_prev) {                   // Set-up
-      a_prev = a;
+    if (a != aPrev) {                   // Set-up
+      aPrev = a;
       if (a < 0.97) {
         t = -a / Math.log(1.0 - a);
       } else {
@@ -115,19 +114,19 @@ public class Logarithmic extends Abstrac
 
   /** Sets the distribution parameter. */
   public void setState(double p) {
-    this.my_p = p;
+    this.myP = p;
   }
 
   /** Returns a random number from the distribution. */
   public static double staticNextDouble(double p) {
-    synchronized (shared) {
-      return shared.nextDouble(p);
+    synchronized (SHARED) {
+      return SHARED.nextDouble(p);
     }
   }
 
   /** Returns a String representation of the receiver. */
   public String toString() {
-    return this.getClass().getName() + '(' + my_p + ')';
+    return this.getClass().getName() + '(' + myP + ')';
   }
 
 }

Modified: mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/Normal.java
URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/Normal.java?rev=993365&r1=993364&r2=993365&view=diff
==============================================================================
--- mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/Normal.java (original)
+++ mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/Normal.java Tue Sep  7 13:54:21 2010
@@ -8,7 +8,6 @@ It is provided "as is" without expressed
 */
 package org.apache.mahout.math.jet.random;
 
-import org.apache.mahout.math.jet.random.engine.RandomEngine;
 import org.apache.mahout.math.jet.stat.Probability;
 
 import java.util.Locale;

Modified: mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/Poisson.java
URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/Poisson.java?rev=993365&r1=993364&r2=993365&view=diff
==============================================================================
--- mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/Poisson.java (original)
+++ mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/Poisson.java Tue Sep  7 13:54:21 2010
@@ -250,7 +250,7 @@ public class Poisson extends AbstractDis
 
           // computation of candidate X < k2, and its counterpart Y > k2
           // either squeeze-acceptance of X or acceptance-rejection of Y
-          Dk = (int) (dl * gen.nextDouble()) + 1;
+          Dk = gen.nextInt((int) dl) + 1;
           if (W <= f2 - Dk * (f2 - f2 / r2)) {            // quick accept of
             return (k2 - Dk);                          // X = k2 - Dk
           }
@@ -276,7 +276,7 @@ public class Poisson extends AbstractDis
 
           // computation of candidate X > k4, and its counterpart Y < k4
           // either squeeze-acceptance of X or acceptance-rejection of Y
-          Dk = (int) (dr * gen.nextDouble()) + 1;
+          Dk = gen.nextInt((int) dr) + 1;
           if (W <= f4 - Dk * (f4 - f4 * r4)) {             // quick accept of
             return (k4 + Dk);                           // X = k4 + Dk
           }