Package org.apache.commons.math.stat.descriptive

Examples of org.apache.commons.math.stat.descriptive.SummaryStatistics.addValue()


    public void testTwoSampleTHomoscedastic() throws Exception {
        double[] sample1 ={2, 4, 6, 8, 10, 97};
        double[] sample2 = {4, 6, 8, 10, 16};
        SummaryStatistics sampleStats1 = new SummaryStatistics();
        for (int i = 0; i < sample1.length; i++) {
            sampleStats1.addValue(sample1[i]);
        }
        SummaryStatistics sampleStats2 = new SummaryStatistics();
        for (int i = 0; i < sample2.length; i++) {
            sampleStats2.addValue(sample2[i]);
        }
View Full Code Here


        for (int i = 0; i < sample1.length; i++) {
            sampleStats1.addValue(sample1[i]);
        }
        SummaryStatistics sampleStats2 = new SummaryStatistics();
        for (int i = 0; i < sample2.length; i++) {
            sampleStats2.addValue(sample2[i]);
        }

        // Target comparison values computed using R version 1.8.1 (Linux version)
        assertEquals("two sample homoscedastic t stat", 0.73096310086,
                TestUtils.homoscedasticT(sample1, sample2), 10E-11);
View Full Code Here

    @Test
    public void testGaussian() {
        Well1024a mt = new Well1024a(42853252100l);
        SummaryStatistics sample = new SummaryStatistics();
        for (int i = 0; i < 10000; ++i) {
            sample.addValue(mt.nextGaussian());
        }
        Assert.assertEquals(0.0, sample.getMean(), 0.004);
        Assert.assertEquals(1.0, sample.getStandardDeviation(), 0.003);
    }
View Full Code Here

    @Test
    public void testDouble() {
        Well1024a mt = new Well1024a(195357343514l);
        SummaryStatistics sample = new SummaryStatistics();
        for (int i = 0; i < 10000; ++i) {
            sample.addValue(mt.nextDouble());
        }
        Assert.assertEquals(0.5, sample.getMean(), 0.0006);
        Assert.assertEquals(1.0 / (2.0 * FastMath.sqrt(3.0)),
                     sample.getStandardDeviation(),
                     0.002);
View Full Code Here

        } catch (IllegalArgumentException ex) {
            // ignored
        }
        SummaryStatistics u = new SummaryStatistics();
        for (int i = 0; i < largeSampleSize; i++) {
            u.addValue(randomData.nextGaussian(0, 1));
        }
        double xbar = u.getMean();
        double s = u.getStandardDeviation();
        double n = u.getN();
        /*
 
View Full Code Here

    @Test
    public void testGaussian() {
        MersenneTwister mt = new MersenneTwister(42853252100l);
        SummaryStatistics sample = new SummaryStatistics();
        for (int i = 0; i < 1000; ++i) {
            sample.addValue(mt.nextGaussian());
        }
        assertEquals(0.0, sample.getMean(), 0.005);
        assertEquals(1.0, sample.getStandardDeviation(), 0.025);
    }
View Full Code Here

    @Test
    public void testDouble() {
        MersenneTwister mt = new MersenneTwister(195357343514l);
        SummaryStatistics sample = new SummaryStatistics();
        for (int i = 0; i < 1000; ++i) {
            sample.addValue(mt.nextDouble());
        }
        assertEquals(0.5, sample.getMean(), 0.02);
        assertEquals(1.0 / (2.0 * FastMath.sqrt(3.0)),
                     sample.getStandardDeviation(),
                     0.002);
View Full Code Here

    @Test
    public void testFloat() {
        MersenneTwister mt = new MersenneTwister(4442733263l);
        SummaryStatistics sample = new SummaryStatistics();
        for (int i = 0; i < 1000; ++i) {
            sample.addValue(mt.nextFloat());
        }
        assertEquals(0.5, sample.getMean(), 0.01);
        assertEquals(1.0 / (2.0 * FastMath.sqrt(3.0)),
                     sample.getStandardDeviation(),
                     0.006);
View Full Code Here

    @Test
    public void testFloat() {
        MersenneTwister mt = new MersenneTwister(4442733263l);
        SummaryStatistics sample = new SummaryStatistics();
        for (int i = 0; i < 1000; ++i) {
            sample.addValue(mt.nextFloat());
        }
        assertEquals(0.5, sample.getMean(), 0.01);
        assertEquals(1.0 / (2.0 * Math.sqrt(3.0)),
                     sample.getStandardDeviation(),
                     0.006);
View Full Code Here

        assertTrue("empirical distribution property",
            vs.getEmpiricalDistribution() != null);
        SummaryStatistics stats = new SummaryStatistics();
        for (int i = 1; i < 1000; i++) {
            next = vs.getNext();
            stats.addValue(next);
        }   
        assertEquals("mean", 5.069831575018909, stats.getMean(), tolerance);
        assertEquals
         ("std dev", 1.0173699343977738, stats.getStandardDeviation(),
            tolerance);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.