Search in sources :

Example 1 with SpecialDoubleCells

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);
    }
}
Also used : Mean(org.knime.base.data.statistics.calculation.Mean) MissingValue(org.knime.base.data.statistics.calculation.MissingValue) Kurtosis(org.knime.base.data.statistics.calculation.Kurtosis) DoubleMinMax(org.knime.base.data.statistics.calculation.DoubleMinMax) MinMax(org.knime.base.data.statistics.calculation.MinMax) Variance(org.knime.base.data.statistics.calculation.Variance) DoubleMinMax(org.knime.base.data.statistics.calculation.DoubleMinMax) Skewness(org.knime.base.data.statistics.calculation.Skewness) BufferedDataTable(org.knime.core.node.BufferedDataTable) SpecialDoubleCells(org.knime.base.data.statistics.calculation.SpecialDoubleCells) StandardDeviation(org.knime.base.data.statistics.calculation.StandardDeviation) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 DoubleMinMax (org.knime.base.data.statistics.calculation.DoubleMinMax)1 Kurtosis (org.knime.base.data.statistics.calculation.Kurtosis)1 Mean (org.knime.base.data.statistics.calculation.Mean)1 MinMax (org.knime.base.data.statistics.calculation.MinMax)1 MissingValue (org.knime.base.data.statistics.calculation.MissingValue)1 Skewness (org.knime.base.data.statistics.calculation.Skewness)1 SpecialDoubleCells (org.knime.base.data.statistics.calculation.SpecialDoubleCells)1 StandardDeviation (org.knime.base.data.statistics.calculation.StandardDeviation)1 Variance (org.knime.base.data.statistics.calculation.Variance)1 BufferedDataTable (org.knime.core.node.BufferedDataTable)1