Java Code Examples for org.apache.commons.math.stat.descriptive.SummaryStatistics#addValue()
The following examples show how to use
org.apache.commons.math.stat.descriptive.SummaryStatistics#addValue() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RandomDataTest.java From astor with GNU General Public License v2.0 | 6 votes |
/** test failure modes and distribution of nextGaussian() */ public void testNextGaussian() { try { 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(Math.abs(xbar) / (s / Math.sqrt(n)) < 3.29); }
Example 2
Source File: RandomDataTest.java From astor with GNU General Public License v2.0 | 6 votes |
/** test failure modes and distribution of nextGaussian() */ public void testNextGaussian() { try { 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(Math.abs(xbar) / (s / Math.sqrt(n)) < 3.29); }
Example 3
Source File: PerfTestUtils.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Timing. * * @param repeatChunk Each timing measurement will done done for that * number of repeats of the code. * @param repeatStat Timing will be averaged over that number of runs. * @param runGC Call {@code System.gc()} between each timed block. When * set to {@code true}, the test will run much slower. * @param methods Codes being timed. * @return for each of the given {@code methods}, a * {@link StatisticalSummary} of the average times (in milliseconds) * taken by a single call to the {@code call} method (i.e. the time * taken by each timed block divided by {@code repeatChunk}). */ public static StatisticalSummary[] time(int repeatChunk, int repeatStat, boolean runGC, Callable<Double> ... methods) { final double[][][] times = timesAndResults(repeatChunk, repeatStat, runGC, methods); final int len = methods.length; final StatisticalSummary[] stats = new StatisticalSummary[len]; for (int j = 0; j < len; j++) { final SummaryStatistics s = new SummaryStatistics(); for (int k = 0; k < repeatStat; k++) { s.addValue(times[j][k][0]); } stats[j] = s.getSummary(); } return stats; }
Example 4
Source File: EmpiricalDistributionTest.java From astor with GNU General Public License v2.0 | 5 votes |
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); }
Example 5
Source File: EmpiricalDistributionImpl.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * Computes binStats * * @param min minimum value * @param delta grid size * @throws IOException if an IO error occurs */ public void computeBinStats(double min, double delta) throws IOException { String str = null; double val = 0.0d; while ((str = inputStream.readLine()) != null) { val = Double.parseDouble(str); SummaryStatistics stats = (SummaryStatistics) binStats.get(findBin(min, val, delta)); stats.addValue(val); } inputStream.close(); inputStream = null; }
Example 6
Source File: EmpiricalDistributionImpl.java From astor with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ @Override public void computeStats() throws IOException { sampleStats = new SummaryStatistics(); for (int i = 0; i < inputArray.length; i++) { sampleStats.addValue(inputArray[i]); } }
Example 7
Source File: EmpiricalDistributionTest.java From astor with GNU General Public License v2.0 | 5 votes |
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); }
Example 8
Source File: RandomGeneratorAbstractTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void testFloatDirect() { SummaryStatistics sample = new SummaryStatistics(); for (int i = 0; i < 1000; ++i) { sample.addValue(generator.nextFloat()); } Assert.assertEquals(0.5, sample.getMean(), 0.01); Assert.assertEquals(1.0 / (2.0 * FastMath.sqrt(3.0)), sample.getStandardDeviation(), 0.01); }
Example 9
Source File: MersenneTwisterTest.java From astor with GNU General Public License v2.0 | 5 votes |
@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); }
Example 10
Source File: MersenneTwisterTest.java From astor with GNU General Public License v2.0 | 5 votes |
@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); }
Example 11
Source File: MersenneTwisterTest.java From astor with GNU General Public License v2.0 | 5 votes |
@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); }
Example 12
Source File: EmpiricalDistributionTest.java From astor with GNU General Public License v2.0 | 5 votes |
private void tstGen(double tolerance)throws Exception { empiricalDistribution.load(url); empiricalDistribution.reSeed(1000); SummaryStatistics stats = new SummaryStatistics(); for (int i = 1; i < 1000; i++) { stats.addValue(empiricalDistribution.getNextValue()); } Assert.assertEquals("mean", 5.069831575018909, stats.getMean(),tolerance); Assert.assertEquals("std dev", 1.0173699343977738, stats.getStandardDeviation(),tolerance); }
Example 13
Source File: MersenneTwisterTest.java From astor with GNU General Public License v2.0 | 5 votes |
@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); }
Example 14
Source File: TTestTest.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
public void setUp() { tooShortStats = new SummaryStatistics(); tooShortStats.addValue(0d); }
Example 15
Source File: TTestTest.java From astor with GNU General Public License v2.0 | 4 votes |
@Override public void setUp() { tooShortStats = new SummaryStatistics(); tooShortStats.addValue(0d); }