Example usage for org.apache.commons.math3.stat.descriptive DescriptiveStatistics addValue

List of usage examples for org.apache.commons.math3.stat.descriptive DescriptiveStatistics addValue

Introduction

In this page you can find the example usage for org.apache.commons.math3.stat.descriptive DescriptiveStatistics addValue.

Prototype

public void addValue(double v) 

Source Link

Document

Adds the value to the dataset.

Usage

From source file:org.moeaframework.core.PRNGTest.java

/**
 * Tests if the {@code nextFloat} method produces uniformly-distributed
 * values in the range {@code [0, 1]}.//from w  ww.ja  v a2s .c o m
 */
@Test
public void testNextFloat() {
    DescriptiveStatistics statistics = new DescriptiveStatistics();

    for (int i = 0; i < N; i++) {
        statistics.addValue(PRNG.nextFloat());
    }

    testUniformDistribution(0.0, 1.0, statistics);
}

From source file:org.moeaframework.core.PRNGTest.java

/**
 * Tests if the {@code nextFloat} method produces uniformly-distributed
 * values in a specified range./*from  w w w.jav  a 2  s  .c o  m*/
 */
@Test
public void testNextFloatRange() {
    DescriptiveStatistics statistics = new DescriptiveStatistics();

    for (int i = 0; i < N; i++) {
        statistics.addValue(PRNG.nextFloat(15.0f, 20.0f));
    }

    testUniformDistribution(15.0, 20.0, statistics);
}

From source file:org.moeaframework.core.PRNGTest.java

/**
 * Tests if the {@code nextDouble} method produces uniformly-distributed
 * values in the range {@code [0, 1]}.// w  ww.jav  a2 s  .  co  m
 */
@Test
public void testNextDouble() {
    DescriptiveStatistics statistics = new DescriptiveStatistics();

    for (int i = 0; i < N; i++) {
        statistics.addValue(PRNG.nextDouble());
    }

    testUniformDistribution(0.0, 1.0, statistics);
}

From source file:org.moeaframework.core.PRNGTest.java

/**
 * Tests if the {@code nextDouble} method produces uniformly-distributed
 * values in a specified range.//from w  w  w. j ava  2s .  co m
 */
@Test
public void testNextDoubleRange() {
    DescriptiveStatistics statistics = new DescriptiveStatistics();

    for (int i = 0; i < N; i++) {
        statistics.addValue(PRNG.nextDouble(15.0, 20.0));
    }

    testUniformDistribution(15.0, 20.0, statistics);
}

From source file:org.moeaframework.core.PRNGTest.java

/**
 * Tests if the {@code nextInt} method produces uniformly-distributed
 * values in a specified range./*ww w. j a va  2  s  . c  o  m*/
 */
@Test
public void testNextIntRange1() {
    DescriptiveStatistics statistics = new DescriptiveStatistics();

    for (int i = 0; i < N; i++) {
        statistics.addValue(PRNG.nextInt(15));
    }

    testUniformDistribution(0, 14, statistics);
}

From source file:org.moeaframework.core.PRNGTest.java

/**
 * Tests if the {@code nextInt} method produces uniformly-distributed
 * values in a specified range.// www  .  j  av  a 2 s  .c  o  m
 */
@Test
public void testNextIntRange2() {
    DescriptiveStatistics statistics = new DescriptiveStatistics();

    for (int i = 0; i < N; i++) {
        statistics.addValue(PRNG.nextInt(15, 20));
    }

    testUniformDistribution(15, 20, statistics);
}

From source file:org.moeaframework.core.PRNGTest.java

/**
 * Tests if the {@code nextBoolean} method produces {@code true} and
 * {@code false} with equal probability.
 *///from  w w  w  . j a va 2 s. c  o m
@Test
public void testNextBoolean() {
    DescriptiveStatistics statistics = new DescriptiveStatistics();

    for (int i = 0; i < N; i++) {
        statistics.addValue(PRNG.nextBoolean() ? 1 : 0);
    }

    testUniformDistribution(0, 1, statistics);
}

From source file:org.moeaframework.core.PRNGTest.java

/**
 * Tests if the {@code nextGaussian} method produces a Gaussian distribution
 * with mean {@code 0} and standard deviation {@code 1}.
 *///from   w  w  w  .  j a v  a2  s  .co m
@Test
public void testNextGaussian() {
    DescriptiveStatistics statistics = new DescriptiveStatistics();

    for (int i = 0; i < N; i++) {
        statistics.addValue(PRNG.nextGaussian());
    }

    testGaussianDistribution(0.0, 1.0, statistics);
}

From source file:org.moeaframework.core.PRNGTest.java

/**
 * Tests if the {@code nextGaussian} method produces a Gaussian distribution
 * with a specified mean and standard deviation.
 *///from  w  ww .  j a  v a 2s. c  o m
@Test
public void testNextGaussianParameterized() {
    DescriptiveStatistics statistics = new DescriptiveStatistics();

    for (int i = 0; i < N; i++) {
        statistics.addValue(PRNG.nextGaussian(5.0, 2.0));
    }

    testGaussianDistribution(5.0, 2.0, statistics);
}

From source file:org.moeaframework.util.sequence.SequenceTest.java

/**
 * Asserts the samples are uniformly distributed.
 * /*from  ww  w . j a  v a 2 s  .com*/
 * @param points the samples
 * @param D the dimension of the samples
 */
protected void checkStatistics(double[][] points, int D) {
    for (int i = 0; i < D; i++) {
        DescriptiveStatistics statistics = new DescriptiveStatistics();

        for (int j = 0; j < points.length; j++) {
            statistics.addValue(points[j][i]);
        }

        testUniformDistribution(0.0, 1.0, statistics);
    }
}