If other objects have already been added to this Frequency, v must be comparable to those that have already been added.
v
299300301302303304305306307308309
private void checkNextSecureIntUniform(int min, int max) throws Exception { final Frequency freq = new Frequency(); for (int i = 0; i < smallSampleSize; i++) { final int value = randomData.nextSecureInt(min, max); Assert.assertTrue("nextInt range", (value >= min) && (value <= max)); freq.addValue(value); } final int len = max - min + 1; final long[] observed = new long[len]; for (int i = 0; i < len; i++) { observed[i] = freq.getCount(min + i);
332333334335336337338339340341342
} catch (MathIllegalArgumentException ex) { // ignored } Frequency f = new Frequency(); for (int i = 0; i < largeSampleSize; i++) { f.addValue(randomData.nextPoisson(4.0d)); } long cumFreq = f.getCount(0) + f.getCount(1) + f.getCount(2) + f.getCount(3) + f.getCount(4) + f.getCount(5); long sumFreq = f.getSumFreq(); double cumPct = Double.valueOf(cumFreq).doubleValue()
394395396397398399400401402403404
for (int i = 0; i < sampleSize; i++) { long value = randomData.nextPoisson(mean); if (value > maxObservedValue) { maxObservedValue = value; } frequency.addValue(value); } /* * Set up bins for chi-square test. * Ensure expected counts are all at least minExpectedCount.
542543544545546547548549550551552
hexString = randomData.nextHexString(100); if (hexString.length() != 100) { Assert.fail("incorrect length for generated string"); } for (int j = 0; j < hexString.length(); j++) { f.addValue(hexString.substring(j, j + 1)); } } double[] expected = new double[16]; long[] observed = new long[16]; for (int i = 0; i < 16; i++) {
598599600601602603604605606607608
hexString = randomData.nextSecureHexString(100); if (hexString.length() != 100) { Assert.fail("incorrect length for generated string"); } for (int j = 0; j < hexString.length(); j++) { f.addValue(hexString.substring(j, j + 1)); } } double[] expected = new double[16]; long[] observed = new long[16]; for (int i = 0; i < 16; i++) {
696697698699700701702703704705706
// Find bin int j = 0; while (j < binCount - 1 && value > binBounds[j]) { j++; } freq.addValue(j); } final long[] observed = new long[binCount]; for (int i = 0; i < binCount; i++) { observed[i] = freq.getCount(i);
776777778779780781782783784785786
public static double[] normalize(final double[] sample) { DescriptiveStatistics stats = new DescriptiveStatistics(); // Add the data from the series to stats for (int i = 0; i < sample.length; i++) { stats.addValue(sample[i]); } // Compute mean and standard deviation double mean = stats.getMean(); double standardDeviation = stats.getStandardDeviation();
495496497498499500501502503504505
double standardizedSample[] = StatUtils.normalize(sample); DescriptiveStatistics stats = new DescriptiveStatistics(); // Add the data from the array for (int i = 0; i < length; i++) { stats.addValue(standardizedSample[i]); } // the calculations do have a limited precision double distance = 1E-10; // check the mean an standard deviation Assert.assertEquals(0.0, stats.getMean(), distance);
135136137138139140141142143144145
line = in.readLine(); while (line != null) { if (d != null) { d.addValue(Double.parseDouble(line.trim())); } else { s.addValue(Double.parseDouble(line.trim())); } line = in.readLine(); }
7273747576777879808182
StableRandomGenerator generator = new StableRandomGenerator(rg, 1d, 0.0); DescriptiveStatistics summary = new DescriptiveStatistics(); for (int i = 0; i < sampleSize; ++i) { double sample = generator.nextNormalizedDouble(); summary.addValue(sample); } // Standard Cauchy distribution should have zero median and mode double median = summary.getPercentile(50); Assert.assertEquals(0.0, median, 0.2);