If other objects have already been added to this Frequency, v must be comparable to those that have already been added.
v
385386387388389390391392393394395
@Override public void computeBinStats() throws IOException { for (int i = 0; i < inputArray.length; i++) { SummaryStatistics stats = binStats.get(findBin(inputArray[i])); stats.addValue(inputArray[i]); } } } /**
6263646566676869707172
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;
353354355356357358359360361362363
String str = null; double val = 0.0d; while ((str = inputStream.readLine()) != null) { val = Double.parseDouble(str); SummaryStatistics stats = binStats.get(findBin(val)); stats.addValue(val); } inputStream.close(); inputStream = null; }
410411412413414415416417418419420
138139140141142143144145146147148
while (line != null) { if (d != null) { d.addValue(Double.parseDouble(line.trim())); } else { s.addValue(Double.parseDouble(line.trim())); } line = in.readLine(); } resourceAsStream.close();
287288289290291292293294295296297
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); }
298299300301302303304305306307308
private void tstDoubleGen(double tolerance)throws Exception { empiricalDistribution2.load(dataArray); empiricalDistribution2.reSeed(1000); SummaryStatistics stats = new SummaryStatistics(); for (int i = 1; i < 1000; i++) { stats.addValue(empiricalDistribution2.getNextValue()); } Assert.assertEquals("mean", 5.069831575018909, stats.getMean(), tolerance); Assert.assertEquals("std dev", 1.0173699343977738, stats.getStandardDeviation(), tolerance); }
204205206207208209210211212213214
{93.0, 103.0, 95.0, 101.0, 91.0, 105.0, 96.0, 94.0, 101.0, 88.0, 98.0, 94.0, 101.0, 92.0, 95.0 }; double mu = 100.0; SummaryStatistics sampleStats = null; sampleStats = new SummaryStatistics(); for (int i = 0; i < observed.length; i++) { sampleStats.addValue(observed[i]); } // Target comparison values computed using R version 1.8.1 (Linux version) Assert.assertEquals("t statistic", -2.81976445346, TestUtils.t(mu, observed), 10E-10);
263264265266267268269270271272273
@Test public void testDoubleDirect() { SummaryStatistics sample = new SummaryStatistics(); final int N = 10000; for (int i = 0; i < N; ++i) { sample.addValue(generator.nextDouble()); } Assert.assertEquals("Note: This test will fail randomly about 1 in 100 times.", 0.5, sample.getMean(), FastMath.sqrt(N/12.0) * 2.576); Assert.assertEquals(1.0 / (2.0 * FastMath.sqrt(3.0)), sample.getStandardDeviation(), 0.01);
276277278279280281282283284285286
@Test public void testFloatDirect() { SummaryStatistics sample = new SummaryStatistics(); final int N = 1000; for (int i = 0; i < N; ++i) { sample.addValue(generator.nextFloat()); } Assert.assertEquals("Note: This test will fail randomly about 1 in 100 times.", 0.5, sample.getMean(), FastMath.sqrt(N/12.0) * 2.576); Assert.assertEquals(1.0 / (2.0 * FastMath.sqrt(3.0)), sample.getStandardDeviation(), 0.01);