Example usage for org.apache.commons.math3.distribution NormalDistribution reseedRandomGenerator

List of usage examples for org.apache.commons.math3.distribution NormalDistribution reseedRandomGenerator

Introduction

In this page you can find the example usage for org.apache.commons.math3.distribution NormalDistribution reseedRandomGenerator.

Prototype

public void reseedRandomGenerator(long seed) 

Source Link

Usage

From source file:edu.cudenver.bios.matrix.DesignEssenceMatrix.java

/**
 * Fills in a random column in the full design matrix
 *
 * @param randomColumn column index in random submatrix
 * @param fullColumn column index in full design matrix
 * @param fullDesign full design matrix//from  w  w  w . j a va  2 s  . c om
 */
private void fillRandomColumn(int randomColumn, int fullColumn, RealMatrix fullDesign) {
    // if the column represents a random predictor, build a normal distribution
    // from which to pull random values
    NormalDistribution dist = null;
    // note, the jsc library takes a standard deviation, not a variance so
    // we take the square root
    dist = new NormalDistribution(randomColMetaData[randomColumn].getMean(),
            Math.sqrt(randomColMetaData[randomColumn].getVariance()));
    dist.reseedRandomGenerator(randomSeed);

    for (int row = 0; row < fullDesign.getRowDimension(); row++) {
        // fill in the data
        fullDesign.setEntry(row, fullColumn, dist.sample());
    }
}

From source file:org.apache.spark.ml.stat.JavaKolmogorovSmirnovTestSuite.java

@Test
public void testKSTestCDF() {
    // Create theoretical distributions
    NormalDistribution stdNormalDist = new NormalDistribution(0, 1);

    // set seeds// w  w w  .  j a  v a2 s .c  om
    Long seed = 10L;
    stdNormalDist.reseedRandomGenerator(seed);
    Function<Double, Double> stdNormalCDF = (x) -> stdNormalDist.cumulativeProbability(x);

    double pThreshold = 0.05;

    // Comparing a standard normal sample to a standard normal distribution
    Row results = KolmogorovSmirnovTest.test(dataset, "sample", stdNormalCDF).head();
    double pValue1 = results.getDouble(0);
    // Cannot reject null hypothesis
    assert (pValue1 > pThreshold);
}