Search in sources :

Example 6 with IntCell

use of org.knime.core.data.def.IntCell in project knime-core by knime.

the class LeveneTestStatistics method getLeveneTestTwoGroupsCells.

/**
 * Get the test result of the Levene test. This is an optimized version for
 * two groups.
 * @return the Levene test
 */
public List<List<DataCell>> getLeveneTestTwoGroupsCells() {
    SummaryStatistics statsX = m_denStats.get(0);
    SummaryStatistics statsY = m_denStats.get(1);
    // overall sample mean
    double m = m_lstats.getMean();
    // first sample mean
    double m1 = statsX.getMean();
    // second sample mean
    double m2 = statsY.getMean();
    // first sample variance
    double v1 = statsX.getVariance();
    // second sample variance
    double v2 = statsY.getVariance();
    // first sample count
    double n1 = statsX.getN();
    // second sample count
    double n2 = statsY.getN();
    // Levene's test
    double num = n1 * (m1 - m) * (m1 - m) + n2 * (m2 - m) * (m2 - m);
    double den = (n1 - 1) * v1 + (n2 - 1) * v2;
    double L = (n1 + n2 - 2) / den * num;
    long df1 = 1;
    long df2 = (long) n1 + (long) n2 - 2;
    FDistribution distribution = new FDistribution(df1, df2);
    double pValue = 1 - distribution.cumulativeProbability(L);
    List<DataCell> cells = new ArrayList<DataCell>();
    cells.add(new StringCell(m_column));
    cells.add(new DoubleCell(L));
    cells.add(new IntCell((int) df1));
    cells.add(new IntCell((int) df2));
    cells.add(new DoubleCell(pValue));
    return Collections.singletonList(cells);
}
Also used : StringCell(org.knime.core.data.def.StringCell) DoubleCell(org.knime.core.data.def.DoubleCell) ArrayList(java.util.ArrayList) SummaryStatistics(org.apache.commons.math3.stat.descriptive.SummaryStatistics) DataCell(org.knime.core.data.DataCell) FDistribution(org.apache.commons.math3.distribution.FDistribution) IntCell(org.knime.core.data.def.IntCell)

Example 7 with IntCell

use of org.knime.core.data.def.IntCell in project knime-core by knime.

the class OneWayANOVAStatistics method getGroupStatistics.

/**
 * Get descriptive statistics for the given Group.
 * @param groupIndex the index of the group
 * @return the descriptive statistics for this group.
 */
public List<DataCell> getGroupStatistics(final int groupIndex) {
    List<DataCell> cells = new ArrayList<DataCell>();
    cells.add(new StringCell(m_column));
    cells.add(new StringCell(m_groups.get(groupIndex)));
    SummaryStatistics stats = m_gstats.get(groupIndex);
    cells.add(new IntCell((int) stats.getN()));
    cells.add(new IntCell(m_missing.get(groupIndex).intValue()));
    cells.add(new IntCell(m_missingGroup.intValue()));
    cells.add(new DoubleCell(stats.getMean()));
    cells.add(new DoubleCell(stats.getStandardDeviation()));
    cells.add(new DoubleCell(StatsUtil.getStandardError(stats)));
    cells.add(new DoubleCell(m_confidenceIntervalProp));
    long df = stats.getN() - 1;
    TDistribution distribution = new TDistribution(df);
    double tValue = FastMath.abs(distribution.inverseCumulativeProbability((1 - m_confidenceIntervalProp) / 2));
    double confidenceDelta = tValue * StatsUtil.getStandardError(stats);
    double confidenceLowerBound = stats.getMean() - confidenceDelta;
    double confidenceUpperBound = stats.getMean() + confidenceDelta;
    cells.add(new DoubleCell(confidenceLowerBound));
    cells.add(new DoubleCell(confidenceUpperBound));
    cells.add(new DoubleCell(stats.getMin()));
    cells.add(new DoubleCell(stats.getMax()));
    return cells;
}
Also used : StringCell(org.knime.core.data.def.StringCell) DoubleCell(org.knime.core.data.def.DoubleCell) ArrayList(java.util.ArrayList) DataCell(org.knime.core.data.DataCell) SummaryStatistics(org.apache.commons.math3.stat.descriptive.SummaryStatistics) TDistribution(org.apache.commons.math3.distribution.TDistribution) IntCell(org.knime.core.data.def.IntCell)

Example 8 with IntCell

use of org.knime.core.data.def.IntCell in project knime-core by knime.

the class OneWayANOVAStatistics method getGroupsTotalStatistics.

/**
 * Get descriptive statistics for all groups.
 * @return the descriptive statistics for all groups
 */
public List<DataCell> getGroupsTotalStatistics() {
    List<DataCell> cells = new ArrayList<DataCell>();
    cells.add(new StringCell(m_column));
    cells.add(new StringCell("Total"));
    SummaryStatistics stats = m_stats;
    cells.add(new IntCell((int) stats.getN()));
    int missingCount = 0;
    for (MutableInteger m : m_missing) {
        missingCount += m.intValue();
    }
    cells.add(new IntCell(missingCount));
    cells.add(new IntCell(m_missingGroup.intValue()));
    cells.add(new DoubleCell(stats.getMean()));
    cells.add(new DoubleCell(stats.getStandardDeviation()));
    cells.add(new DoubleCell(StatsUtil.getStandardError(stats)));
    cells.add(new DoubleCell(m_confidenceIntervalProp));
    long df = stats.getN() - 1;
    TDistribution distribution = new TDistribution(df);
    double tValue = FastMath.abs(distribution.inverseCumulativeProbability((1 - m_confidenceIntervalProp) / 2));
    double confidenceDelta = tValue * StatsUtil.getStandardError(stats);
    double confidenceLowerBound = stats.getMean() - confidenceDelta;
    double confidenceUpperBound = stats.getMean() + confidenceDelta;
    cells.add(new DoubleCell(confidenceLowerBound));
    cells.add(new DoubleCell(confidenceUpperBound));
    cells.add(new DoubleCell(stats.getMin()));
    cells.add(new DoubleCell(stats.getMax()));
    return cells;
}
Also used : StringCell(org.knime.core.data.def.StringCell) DoubleCell(org.knime.core.data.def.DoubleCell) MutableInteger(org.knime.core.util.MutableInteger) ArrayList(java.util.ArrayList) DataCell(org.knime.core.data.DataCell) SummaryStatistics(org.apache.commons.math3.stat.descriptive.SummaryStatistics) TDistribution(org.apache.commons.math3.distribution.TDistribution) IntCell(org.knime.core.data.def.IntCell)

Example 9 with IntCell

use of org.knime.core.data.def.IntCell in project knime-core by knime.

the class OneWayANOVAStatistics method getTotal.

/**
 * Get the row of the ANOVA table with the cells "Total".
 */
private List<DataCell> getTotal(final ANOVA anova) {
    List<DataCell> cells = new ArrayList<DataCell>();
    cells.add(new StringCell(m_column));
    cells.add(new StringCell(SOURCE_TOTAL));
    cells.add(new DoubleCell(anova.getSqurb() + anova.getSquri()));
    cells.add(new IntCell((int) (anova.getDfb() + anova.getDfi())));
    cells.add(DataType.getMissingCell());
    cells.add(DataType.getMissingCell());
    cells.add(DataType.getMissingCell());
    return cells;
}
Also used : StringCell(org.knime.core.data.def.StringCell) DoubleCell(org.knime.core.data.def.DoubleCell) ArrayList(java.util.ArrayList) DataCell(org.knime.core.data.DataCell) IntCell(org.knime.core.data.def.IntCell)

Example 10 with IntCell

use of org.knime.core.data.def.IntCell in project knime-core by knime.

the class OneSampleTTestStatistics method getDescStats.

/**
 * Get descriptive statistics for the given column
 * @param rowID the row key
 * @param column the name of the column
 * @param stats the statistics of the column
 * @param missing the missing values in this column
 * @return a DataRow with descriptive statistics
 */
private List<DataCell> getDescStats(final String column, final SummaryStatistics stats, final MutableInteger missing) {
    List<DataCell> cells = new ArrayList<DataCell>();
    cells.add(new StringCell(column));
    cells.add(new IntCell((int) stats.getN()));
    cells.add(new IntCell(missing.intValue()));
    cells.add(new DoubleCell(stats.getMean()));
    cells.add(new DoubleCell(stats.getStandardDeviation()));
    cells.add(new DoubleCell(StatsUtil.getStandardError(stats)));
    return cells;
}
Also used : StringCell(org.knime.core.data.def.StringCell) DoubleCell(org.knime.core.data.def.DoubleCell) ArrayList(java.util.ArrayList) DataCell(org.knime.core.data.DataCell) IntCell(org.knime.core.data.def.IntCell)

Aggregations

IntCell (org.knime.core.data.def.IntCell)109 DataCell (org.knime.core.data.DataCell)79 DoubleCell (org.knime.core.data.def.DoubleCell)67 StringCell (org.knime.core.data.def.StringCell)55 DefaultRow (org.knime.core.data.def.DefaultRow)46 DataRow (org.knime.core.data.DataRow)33 DataTableSpec (org.knime.core.data.DataTableSpec)21 RowKey (org.knime.core.data.RowKey)21 ArrayList (java.util.ArrayList)20 DataType (org.knime.core.data.DataType)20 LongCell (org.knime.core.data.def.LongCell)14 BufferedDataContainer (org.knime.core.node.BufferedDataContainer)14 DataColumnSpecCreator (org.knime.core.data.DataColumnSpecCreator)12 BufferedDataTable (org.knime.core.node.BufferedDataTable)12 Test (org.junit.Test)11 DataColumnSpec (org.knime.core.data.DataColumnSpec)11 ColumnRearranger (org.knime.core.data.container.ColumnRearranger)9 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)9 DataContainer (org.knime.core.data.container.DataContainer)8 DateAndTimeValue (org.knime.core.data.date.DateAndTimeValue)8