commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject [3/3] [math] Example code updated.
Date Mon, 28 Mar 2016 01:45:01 GMT
Example code updated.

Usage of "JDKRandomAdaptor".


Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/880b0481
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/880b0481
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/880b0481

Branch: refs/heads/feature-MATH-1158
Commit: 880b04814c564ea7a1bb8fe97c15b4735c67e8e9
Parents: 3411f29
Author: Gilles <erans@apache.org>
Authored: Mon Mar 28 03:26:52 2016 +0200
Committer: Gilles <erans@apache.org>
Committed: Mon Mar 28 03:26:52 2016 +0200

----------------------------------------------------------------------
 .../math4/userguide/ClusterAlgorithmComparison.java | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/880b0481/src/userguide/java/org/apache/commons/math4/userguide/ClusterAlgorithmComparison.java
----------------------------------------------------------------------
diff --git a/src/userguide/java/org/apache/commons/math4/userguide/ClusterAlgorithmComparison.java
b/src/userguide/java/org/apache/commons/math4/userguide/ClusterAlgorithmComparison.java
index b33c3cf..9dbd1c2 100644
--- a/src/userguide/java/org/apache/commons/math4/userguide/ClusterAlgorithmComparison.java
+++ b/src/userguide/java/org/apache/commons/math4/userguide/ClusterAlgorithmComparison.java
@@ -46,7 +46,7 @@ import org.apache.commons.math4.ml.clustering.DBSCANClusterer;
 import org.apache.commons.math4.ml.clustering.DoublePoint;
 import org.apache.commons.math4.ml.clustering.FuzzyKMeansClusterer;
 import org.apache.commons.math4.ml.clustering.KMeansPlusPlusClusterer;
-import org.apache.commons.math4.random.RandomAdaptor;
+import org.apache.commons.math4.random.JDKRandomAdaptor;
 import org.apache.commons.math4.random.SobolSequenceGenerator;
 import org.apache.commons.math4.rng.UniformRandomProvider;
 import org.apache.commons.math4.rng.RandomSource;
@@ -84,8 +84,7 @@ public class ClusterAlgorithmComparison {
         }
         
         if (shuffle) {
-            // Collections.shuffle(points, new RandomAdaptor(rng)); // XXX TODO
-            Collections.shuffle(points); // XXX temporary workaround
+            Collections.shuffle(points, new JDKRandomAdaptor(rng));
         }
 
         return points;
@@ -115,8 +114,7 @@ public class ClusterAlgorithmComparison {
         }
         
         if (shuffle) {
-            // Collections.shuffle(points, new RandomAdaptor(rng)); // XXX TODO
-            Collections.shuffle(points); // XXX temporary workaround
+            Collections.shuffle(points, new JDKRandomAdaptor(rng));
         }
 
         return points;
@@ -153,8 +151,7 @@ public class ClusterAlgorithmComparison {
         }
         
         if (shuffle) {
-            // Collections.shuffle(points, new RandomAdaptor(rng)); // XXX TODO
-            Collections.shuffle(points); // XXX temporary workaround
+            Collections.shuffle(points, new JDKRandomAdaptor(rng));
         }
 
         return points;
@@ -206,8 +203,9 @@ public class ClusterAlgorithmComparison {
             setLayout(new GridBagLayout());
             
             int nSamples = 1500;
-            
-            UniformRandomProvider rng = RandomSource.create(RandomSource.WELL_19937_C, 0);
+
+            final long seed = RandomSource.createLong(); // Random seed.
+            UniformRandomProvider rng = RandomSource.create(RandomSource.WELL_19937_C, seed);
             List<List<DoublePoint>> datasets = new ArrayList<List<DoublePoint>>();
 
             datasets.add(normalize(makeCircles(nSamples, true, 0.04, 0.5, rng), -1, 1, -1,
1));


Mime
View raw message