Example code updated.

Usage of "JDKRandomAdaptor".
This commit is contained in:
Gilles 2016-03-28 03:26:52 +02:00
parent 3411f29e23
commit 880b04814c
1 changed files with 7 additions and 9 deletions

View File

@ -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.DoublePoint;
import org.apache.commons.math4.ml.clustering.FuzzyKMeansClusterer; import org.apache.commons.math4.ml.clustering.FuzzyKMeansClusterer;
import org.apache.commons.math4.ml.clustering.KMeansPlusPlusClusterer; 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.random.SobolSequenceGenerator;
import org.apache.commons.math4.rng.UniformRandomProvider; import org.apache.commons.math4.rng.UniformRandomProvider;
import org.apache.commons.math4.rng.RandomSource; import org.apache.commons.math4.rng.RandomSource;
@ -84,8 +84,7 @@ public class ClusterAlgorithmComparison {
} }
if (shuffle) { if (shuffle) {
// Collections.shuffle(points, new RandomAdaptor(rng)); // XXX TODO Collections.shuffle(points, new JDKRandomAdaptor(rng));
Collections.shuffle(points); // XXX temporary workaround
} }
return points; return points;
@ -115,8 +114,7 @@ public class ClusterAlgorithmComparison {
} }
if (shuffle) { if (shuffle) {
// Collections.shuffle(points, new RandomAdaptor(rng)); // XXX TODO Collections.shuffle(points, new JDKRandomAdaptor(rng));
Collections.shuffle(points); // XXX temporary workaround
} }
return points; return points;
@ -153,8 +151,7 @@ public class ClusterAlgorithmComparison {
} }
if (shuffle) { if (shuffle) {
// Collections.shuffle(points, new RandomAdaptor(rng)); // XXX TODO Collections.shuffle(points, new JDKRandomAdaptor(rng));
Collections.shuffle(points); // XXX temporary workaround
} }
return points; return points;
@ -207,7 +204,8 @@ public class ClusterAlgorithmComparison {
int nSamples = 1500; 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>>(); List<List<DoublePoint>> datasets = new ArrayList<List<DoublePoint>>();
datasets.add(normalize(makeCircles(nSamples, true, 0.04, 0.5, rng), -1, 1, -1, 1)); datasets.add(normalize(makeCircles(nSamples, true, 0.04, 0.5, rng), -1, 1, -1, 1));