List of usage examples for org.apache.commons.math.random JDKRandomGenerator setSeed
public void setSeed(int[] seed)
From source file:lfsom.visualization.clustering.LFSKMeans.java
/** * cluster centres are initialised by equally sized random chunks of the * input data when there's 150 instances, we assign 50 chosen randomly to * each cluster and calculate its centre from these (the last cluster might * be larger if numInstances mod k < 0) */// ww w . jav a 2s .c om private void initClustersEqualNumbers() { HashSet<Integer> usedIndices = new HashSet<Integer>(); int limit = numberOfInstances / k; // FIXME: Test clustering with new permutation generator! // int[] randPermIndices = RandomTools.permutation(new // Random(RANDOM_SEED), this.numberOfInstances); JDKRandomGenerator rg = new JDKRandomGenerator(); rg.setSeed(RANDOM_SEED); int[] randPermIndices = new RandomDataImpl(rg).nextPermutation(this.numberOfInstances, this.numberOfInstances); for (int clusterIndex = 0; clusterIndex < k; clusterIndex++) { LFSCluster c = new LFSCluster(new double[data[0].length]); // System.out.println("cluster: " + clusterIndex); for (int randPermIndice : randPermIndices) { int currentIndex = randPermIndice; if ((c.getNumberOfInstances() < limit || clusterIndex == k - 1) && !usedIndices.contains(currentIndex)) { c.addIndex(currentIndex); usedIndices.add(currentIndex); // System.out.print(" " + currentIndex); } } // System.out.println(); c.calculateCentroid(data); // clusters[clusterIndex] = c; clusters[clusterIndex] = new LFSCluster(c.getCentroid()); } }
From source file:org.hippoecm.hst.demo.addonmodules.randomnumbers.RandomGeneratorImpl.java
public RandomGeneratorImpl() { JDKRandomGenerator rg = new JDKRandomGenerator(); rg.setSeed(System.currentTimeMillis()); generator = new UniformRandomGenerator(rg); }