mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sro...@apache.org
Subject svn commit: r1001512 - in /mahout/trunk: core/src/test/java/org/apache/mahout/classifier/sgd/ math/src/test/java/org/apache/mahout/math/ math/src/test/java/org/apache/mahout/math/decomposer/ math/src/test/java/org/apache/mahout/math/jet/random/ math/sr...
Date Sun, 26 Sep 2010 20:57:24 GMT
Author: srowen
Date: Sun Sep 26 20:57:24 2010
New Revision: 1001512

URL: http://svn.apache.org/viewvc?rev=1001512&view=rev
Log:
Replacing some unnecessarily seeded RNGs with regular ones, mostly for consistency

Modified:
    mahout/trunk/core/src/test/java/org/apache/mahout/classifier/sgd/ModelSerializerTest.java
    mahout/trunk/math/src/test/java/org/apache/mahout/math/MatrixTest.java
    mahout/trunk/math/src/test/java/org/apache/mahout/math/TestSingularValueDecomposition.java
    mahout/trunk/math/src/test/java/org/apache/mahout/math/decomposer/SolverTest.java
    mahout/trunk/math/src/test/java/org/apache/mahout/math/jet/random/NormalTest.java
    mahout/trunk/math/src/test/java/org/apache/mahout/math/jet/stat/GammaTest.java

Modified: mahout/trunk/core/src/test/java/org/apache/mahout/classifier/sgd/ModelSerializerTest.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/test/java/org/apache/mahout/classifier/sgd/ModelSerializerTest.java?rev=1001512&r1=1001511&r2=1001512&view=diff
==============================================================================
--- mahout/trunk/core/src/test/java/org/apache/mahout/classifier/sgd/ModelSerializerTest.java
(original)
+++ mahout/trunk/core/src/test/java/org/apache/mahout/classifier/sgd/ModelSerializerTest.java
Sun Sep 26 20:57:24 2010
@@ -64,7 +64,7 @@ public final class ModelSerializerTest e
   public void onlineAucRoundtrip() {
     RandomUtils.useTestSeed();
     OnlineAuc auc1 = new GlobalOnlineAuc();
-    Random gen = RandomUtils.getRandom(2L);
+    Random gen = RandomUtils.getRandom();
     for (int i = 0; i < 10000; i++) {
       auc1.addSample(0, gen.nextGaussian());
       auc1.addSample(1, gen.nextGaussian() + 1);
@@ -162,7 +162,7 @@ public final class ModelSerializerTest e
 
   @Test
   public void trainingExampleList() {
-    Random gen = RandomUtils.getRandom(1L);
+    Random gen = RandomUtils.getRandom();
     List<AdaptiveLogisticRegression.TrainingExample> x1 = Lists.newArrayList();
     for (int i = 0; i < 10; i++) {
       AdaptiveLogisticRegression.TrainingExample t =
@@ -189,7 +189,7 @@ public final class ModelSerializerTest e
 
   private static void train(OnlineLearner olr, int n) {
     Vector beta = new DenseVector(new double[]{1, -1, 0, 0.5, -0.5});
-    Random gen = RandomUtils.getRandom(1L);
+    Random gen = RandomUtils.getRandom();
     for (int i = 0; i < n; i++) {
       Vector x = randomVector(gen, 5);
 

Modified: mahout/trunk/math/src/test/java/org/apache/mahout/math/MatrixTest.java
URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/test/java/org/apache/mahout/math/MatrixTest.java?rev=1001512&r1=1001511&r2=1001512&view=diff
==============================================================================
--- mahout/trunk/math/src/test/java/org/apache/mahout/math/MatrixTest.java (original)
+++ mahout/trunk/math/src/test/java/org/apache/mahout/math/MatrixTest.java Sun Sep 26 20:57:24
2010
@@ -251,7 +251,7 @@ public abstract class MatrixTest extends
     assertEquals(c[COL], test.viewRow(3).size());
     assertEquals(c[COL], test.viewRow(5).size());
 
-    Random gen = RandomUtils.getRandom(1L);
+    Random gen = RandomUtils.getRandom();
     for (int row = 0; row < c[ROW]; row++) {
       int j = gen.nextInt(c[COL]);
       double old = test.get(row, j);
@@ -275,7 +275,7 @@ public abstract class MatrixTest extends
     assertEquals(c[ROW], test.viewColumn(3).size());
     assertEquals(c[ROW], test.viewColumn(5).size());
 
-    Random gen = RandomUtils.getRandom(1L);
+    Random gen = RandomUtils.getRandom();
     for (int col = 0; col < c[COL]; col++) {
       int j = gen.nextInt(c[COL]);
       double old = test.get(col, j);

Modified: mahout/trunk/math/src/test/java/org/apache/mahout/math/TestSingularValueDecomposition.java
URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/test/java/org/apache/mahout/math/TestSingularValueDecomposition.java?rev=1001512&r1=1001511&r2=1001512&view=diff
==============================================================================
--- mahout/trunk/math/src/test/java/org/apache/mahout/math/TestSingularValueDecomposition.java
(original)
+++ mahout/trunk/math/src/test/java/org/apache/mahout/math/TestSingularValueDecomposition.java
Sun Sep 26 20:57:24 2010
@@ -44,7 +44,7 @@ public final class TestSingularValueDeco
     double[] singularValues = { 123.456, 2.3, 1.001, 0.999 };
     int rows    = singularValues.length + 2;
     int columns = singularValues.length;
-    Random r = RandomUtils.getRandom(15338437322523L);
+    Random r = RandomUtils.getRandom();
     SingularValueDecomposition svd =
       new SingularValueDecomposition(createTestMatrix(r, rows, columns, singularValues));
     double[] computedSV = svd.getSingularValues();
@@ -59,7 +59,7 @@ public final class TestSingularValueDeco
     double[] singularValues = { 123.456, 2.3, 1.001, 0.999 };
     int rows    = singularValues.length;
     int columns = singularValues.length + 2;
-    Random r = RandomUtils.getRandom(732763225836210L);
+    Random r = RandomUtils.getRandom();
     SingularValueDecomposition svd =
       new SingularValueDecomposition(createTestMatrix(r, rows, columns, singularValues));
     double[] computedSV = svd.getSingularValues();

Modified: mahout/trunk/math/src/test/java/org/apache/mahout/math/decomposer/SolverTest.java
URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/test/java/org/apache/mahout/math/decomposer/SolverTest.java?rev=1001512&r1=1001511&r2=1001512&view=diff
==============================================================================
--- mahout/trunk/math/src/test/java/org/apache/mahout/math/decomposer/SolverTest.java (original)
+++ mahout/trunk/math/src/test/java/org/apache/mahout/math/decomposer/SolverTest.java Sun
Sep 26 20:57:24 2010
@@ -17,6 +17,7 @@
 
 package org.apache.mahout.math.decomposer;
 
+import org.apache.mahout.common.RandomUtils;
 import org.apache.mahout.math.MahoutTestCase;
 import org.apache.mahout.math.Matrix;
 import org.apache.mahout.math.SequentialAccessSparseVector;
@@ -83,8 +84,7 @@ public abstract class SolverTest extends
                                                           double entryMean) {
     SparseRowMatrix m = new SparseRowMatrix(new int[]{numRows, numCols});
     //double n = 0;
-    // TODO figure out how to redo the test so this can use RandomUtils
-    Random r = new Random(1234L);
+    Random r = RandomUtils.getRandom();
     for (int i = 0; i < nonNullRows; i++) {
       SequentialAccessSparseVector v = new SequentialAccessSparseVector(numCols);
       for (int j = 0; j < entriesPerRow; j++) {

Modified: mahout/trunk/math/src/test/java/org/apache/mahout/math/jet/random/NormalTest.java
URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/test/java/org/apache/mahout/math/jet/random/NormalTest.java?rev=1001512&r1=1001511&r2=1001512&view=diff
==============================================================================
--- mahout/trunk/math/src/test/java/org/apache/mahout/math/jet/random/NormalTest.java (original)
+++ mahout/trunk/math/src/test/java/org/apache/mahout/math/jet/random/NormalTest.java Sun
Sep 26 20:57:24 2010
@@ -33,7 +33,7 @@ public final class NormalTest extends Ma
 
   @Test
   public void testCdf() {
-    Random gen = RandomUtils.getRandom(1L);
+    Random gen = RandomUtils.getRandom();
     double offset = 0;
     double scale = 1;
     for (int k = 0; k < 20; k++) {
@@ -46,7 +46,7 @@ public final class NormalTest extends Ma
 
   @Test
   public void consistency() throws ConvergenceException, FunctionEvaluationException {
-    Random gen = RandomUtils.getRandom(1L);
+    Random gen = RandomUtils.getRandom();
     double offset = 0;
     double scale = 1;
     Normal dist = new Normal(offset, scale, RandomUtils.getRandom());

Modified: mahout/trunk/math/src/test/java/org/apache/mahout/math/jet/stat/GammaTest.java
URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/test/java/org/apache/mahout/math/jet/stat/GammaTest.java?rev=1001512&r1=1001511&r2=1001512&view=diff
==============================================================================
--- mahout/trunk/math/src/test/java/org/apache/mahout/math/jet/stat/GammaTest.java (original)
+++ mahout/trunk/math/src/test/java/org/apache/mahout/math/jet/stat/GammaTest.java Sun Sep
26 20:57:24 2010
@@ -96,7 +96,7 @@ public final class GammaTest extends Mah
 
   @Test
   public void beta() {
-    Random r = RandomUtils.getRandom(1L);
+    Random r = RandomUtils.getRandom();
     for (int i = 0; i < 200; i++) {
       double alpha = -50 * Math.log(1 - r.nextDouble());
       double beta = -50 * Math.log(1 - r.nextDouble());



Mime
View raw message