NumberColumn extends AbstractColumn<C, T> implements NumericColumn<T> { public abstract C copy(); protected  NumberColumn(final ColumnType type, final String name); NumberColumn<C, T> set(DoublePredicate condition, NumberColumn<C, T> other); NumberColumn<C, T> set(DoublePredicate condition, T newValue); void setPrintFormatter(final NumberFormat format, final String missingValueString); void setPrintFormatter(final NumberColumnFormatter formatter); abstract NumericColumn<T> top(final int n); abstract NumericColumn<T> bottom(final int n); @Override String getString(final int row); @Override C emptyCopy(); @Override C emptyCopy(final int rowSize); abstract C copy(); @Override IntComparator rowComparator(); @Override int byteSize(); @Override abstract byte[] asBytes(final int rowNumber); @Override abstract C appendMissing(); @Override int countMissing();  }
@Test public void testPercentiles() { IntColumn c = IntColumn.indexColumn("t", 99, 1); IntColumn c2 = c.copy(); c2.appendCell(""); assertEquals(50, c.median(), 0.00001); assertEquals(50, c2.median(), 0.00001); assertEquals(50, median.summarize(c), 0.00001); assertEquals(25, c.quartile1(), 0.00001); assertEquals(25, c2.quartile1(), 0.00001); assertEquals(25, quartile1.summarize(c), 0.00001); assertEquals(75, c.quartile3(), 0.00001); assertEquals(75, c2.quartile3(), 0.00001); assertEquals(75, quartile3.summarize(c), 0.00001); assertEquals(90, percentile90.summarize(c), 0.00001); assertEquals(5, c2.percentile(5), 0.00001); assertEquals(5, c.percentile(5), 0.00001); assertEquals(5, percentile(c, 5.0), 0.00001); assertEquals(95, percentile95.summarize(c), 0.00001); assertEquals(99, percentile99.summarize(c), 0.00001); }
@Test public void testSummarize() { IntColumn c = IntColumn.indexColumn("t", 99, 1); IntColumn c2 = c.copy(); c2.appendCell(""); double c2Variance = c2.variance(); double cVariance = StatUtils.variance(c.asDoubleArray()); assertEquals(cVariance, c2Variance, 0.00001); assertEquals(StatUtils.sumLog(c.asDoubleArray()), c2.sumOfLogs(), 0.00001); assertEquals(StatUtils.sumSq(c.asDoubleArray()), c2.sumOfSquares(), 0.00001); assertEquals(StatUtils.geometricMean(c.asDoubleArray()), c2.geometricMean(), 0.00001); assertEquals(StatUtils.product(c.asDoubleArray()), c2.product(), 0.00001); assertEquals(StatUtils.populationVariance(c.asDoubleArray()), c2.populationVariance(), 0.00001); assertEquals( new DescriptiveStatistics(c.asDoubleArray()).getQuadraticMean(), c2.quadraticMean(), 0.00001); assertEquals( new DescriptiveStatistics(c.asDoubleArray()).getStandardDeviation(), c2.standardDeviation(), 0.00001); assertEquals( new DescriptiveStatistics(c.asDoubleArray()).getKurtosis(), c2.kurtosis(), 0.00001); assertEquals( new DescriptiveStatistics(c.asDoubleArray()).getSkewness(), c2.skewness(), 0.00001); assertEquals(StatUtils.variance(c.asDoubleArray()), c.variance(), 0.00001); assertEquals(StatUtils.sumLog(c.asDoubleArray()), c.sumOfLogs(), 0.00001); assertEquals(StatUtils.sumSq(c.asDoubleArray()), c.sumOfSquares(), 0.00001); assertEquals(StatUtils.geometricMean(c.asDoubleArray()), c.geometricMean(), 0.00001); assertEquals(StatUtils.product(c.asDoubleArray()), c.product(), 0.00001); assertEquals(StatUtils.populationVariance(c.asDoubleArray()), c.populationVariance(), 0.00001); assertEquals( new DescriptiveStatistics(c.asDoubleArray()).getQuadraticMean(), c.quadraticMean(), 0.00001); assertEquals( new DescriptiveStatistics(c.asDoubleArray()).getStandardDeviation(), c.standardDeviation(), 0.00001); assertEquals(new DescriptiveStatistics(c.asDoubleArray()).getKurtosis(), c.kurtosis(), 0.00001); assertEquals(new DescriptiveStatistics(c.asDoubleArray()).getSkewness(), c.skewness(), 0.00001); }