Example usage for org.apache.commons.math.random RandomGenerator setSeed

List of usage examples for org.apache.commons.math.random RandomGenerator setSeed

Introduction

In this page you can find the example usage for org.apache.commons.math.random RandomGenerator setSeed.

Prototype

void setSeed(long seed);

Source Link

Document

Sets the seed of the underlying random number generator using a long seed.

Usage

From source file:datafu.pig.hash.lsh.interfaces.LSHCreator.java

public RandomGenerator createGenerator() {
    RandomGenerator rg = new JDKRandomGenerator();
    rg.setSeed(seed);
    return rg;
}

From source file:lfsom.visualization.clustering.LFSKMeans.java

/** Take random points from the input data as centroids. */
private void initClustersRandomlyOnInstances() {
    ArrayList<double[]> usedInstances = new ArrayList<double[]>();
    RandomGenerator rg = new JDKRandomGenerator();
    // FIXME: this is for testing purposes only
    rg.setSeed(RANDOM_SEED);
    // for each cluster
    for (int clusterIndex = 0; clusterIndex < k; clusterIndex++) {
        // draw a random input
        double[] centroid = data[rg.nextInt(data.length - 1)].clone();
        while (usedInstances.contains(centroid)) {
            centroid = data[rg.nextInt(data.length - 1)].clone();
        }// w  w  w  .ja v a  2  s  .c  om
        usedInstances.add(centroid);
        clusters[clusterIndex] = new LFSCluster(centroid);
    }
}

From source file:lfsom.visualization.clustering.LFSKMeans.java

/**
 * Calculate random centroids for each cluster.
 *///from  w ww. j  a  v a  2 s. c  o m
private void initClustersRandomly() {
    RandomGenerator rg = new JDKRandomGenerator();
    // FIXME: this is for testing purposes only
    rg.setSeed(RANDOM_SEED);
    // for each cluster
    for (int clusterIndex = 0; clusterIndex < k; clusterIndex++) {
        // for each of its attributes
        double[] centroid = new double[numberOfAttributes];
        for (int attributeIndex = 0; attributeIndex < numberOfAttributes; attributeIndex++) {
            centroid[attributeIndex] = differences[attributeIndex] * rg.nextDouble()
                    + minValues[attributeIndex];
        }
        clusters[clusterIndex] = new LFSCluster(centroid);
    }
    System.out.println("initial centroids: ");
    // printCentroids();
}