use of org.knime.base.data.statistics.calculation.SpecialDoubleCells in project knime-core by knime.
the class StatisticCalculatorTest method testGeneralStats.
/**
* Tests common statistics.
*
* @throws InvalidSettingsException
* @throws CanceledExecutionException
*/
@Test
public void testGeneralStats() throws InvalidSettingsException, CanceledExecutionException {
BufferedDataTable createRandomTable = createRandomTableWithMissingValues(20, 8);
Skewness skewness = new Skewness();
MinMax minMax = new MinMax();
DoubleMinMax doubleMinMax = new DoubleMinMax(true);
Kurtosis kurtosis = new Kurtosis();
Mean mean = new Mean();
Variance variance = new Variance();
StandardDeviation sDev = new StandardDeviation();
MissingValue missingValue = new MissingValue();
SpecialDoubleCells sdc = new SpecialDoubleCells();
StatisticCalculator statisticCalculator = new StatisticCalculator(createRandomTable.getDataTableSpec(), createRandomTable.getSpec().getColumnNames(), skewness, minMax, kurtosis, mean, variance, missingValue, sDev, doubleMinMax, sdc);
statisticCalculator.evaluate(createRandomTable, EXEC_CONTEXT);
Statistics3Table statistics3Table = new Statistics3Table(createRandomTable, false, 0, Collections.<String>emptyList(), EXEC_CONTEXT);
for (int i = 0; i < createRandomTable.getDataTableSpec().getNumColumns(); i++) {
String colName = "" + i;
assertEquals(statistics3Table.getMean(i), mean.getResult(colName), 0.0001);
assertEquals(statistics3Table.getKurtosis(i), kurtosis.getResult(colName), 0.0001);
checkValueOrMissingIfNaN(statistics3Table.getMin()[i], minMax.getMin(colName));
assertEquals(statistics3Table.getMinCells()[i], minMax.getMin(colName));
checkValueOrMissingIfNaN(doubleMinMax.getMin(colName), statistics3Table.getNonInfMin(i));
checkValueOrMissingIfNaN(statistics3Table.getMax()[i], minMax.getMax(colName));
assertEquals(statistics3Table.getMaxCells()[i], minMax.getMax(colName));
checkValueOrMissingIfNaN(doubleMinMax.getMax(colName), statistics3Table.getNonInfMax(i));
assertEquals(statistics3Table.getVariance(i), variance.getResult(colName), 0.0001);
assertEquals(statistics3Table.getStandardDeviation(i), sDev.getResult(colName), 0.0001);
assertEquals(statistics3Table.getNumberMissingValues(i), missingValue.getNumberMissingValues(colName), 0.0001);
assertEquals(statistics3Table.getNumberNegativeInfiniteValues(i), sdc.getNumberNegativeInfiniteValues(colName), 0.0001);
assertEquals(statistics3Table.getNumberPositiveInfiniteValues(i), sdc.getNumberPositiveInfiniteValues(colName), 0.0001);
assertEquals(statistics3Table.getNumberNaNValues(i), sdc.getNumberNaNValues(colName), 0.0001);
}
}
Aggregations