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

Examples of org.apache.commons.math.stat.descriptive.SummaryStatistics


    }

    @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


    }

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

            randomData.nextGaussian(0, 0);
            fail("zero sigma -- IllegalArgumentException expected");
        } 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();
        /*
         * t-test at .001-level TODO: replace with externalized t-test, with
         * test statistic defined in TestStatistic
         */
        assertTrue(FastMath.abs(xbar) / (s / FastMath.sqrt(n)) < 3.29);
View Full Code Here

public class MersenneTwisterTest {

    @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

        double next = 0.0;
        double tolerance = 0.1;
        vs.computeDistribution();
        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);
       
        vs.computeDistribution(500);
        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

        }
    }
   
    private void tstGen(double tolerance)throws Exception {
        empiricalDistribution.load(url);  
        SummaryStatistics stats = new SummaryStatistics();
        for (int i = 1; i < 1000; i++) {
            stats.addValue(empiricalDistribution.getNextValue());
        }
        assertEquals("mean", stats.getMean(),5.069831575018909,tolerance);
        assertEquals
         ("std dev", stats.getStandardDeviation(),1.0173699343977738,tolerance);
    }
View Full Code Here

         ("std dev", stats.getStandardDeviation(),1.0173699343977738,tolerance);
    }

    private void tstDoubleGen(double tolerance)throws Exception {
        empiricalDistribution2.load(dataArray);  
        SummaryStatistics stats = new SummaryStatistics();
        for (int i = 1; i < 1000; i++) {
            stats.addValue(empiricalDistribution2.getNextValue());
        }
        assertEquals("mean", stats.getMean(),5.069831575018909,tolerance);
        assertEquals
         ("std dev", stats.getStandardDeviation(),1.0173699343977738,tolerance);
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.math.stat.descriptive.SummaryStatistics

Copyright © 2018 www.massapicom. 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.