use of org.knime.core.data.def.IntCell in project knime-core by knime.
the class LeveneTestStatistics method getTTestCells.
/**
* Get the test result of the Levene test.
* @return the Levene test
*/
public List<List<DataCell>> getTTestCells() {
if (m_groups.size() == 2) {
// optimized version for two groups
return getLeveneTestTwoGroupsCells();
}
double num = 0;
double Zdd = m_lstats.getMean();
int k = m_groups.size();
for (int i = 0; i < k; i++) {
SummaryStatistics statsGi = m_levenePre.getLgstats().get(i);
double ni = statsGi.getN();
double Zidot = statsGi.getMean();
num += ni * (Zidot - Zdd) * (Zidot - Zdd);
}
double den = 0;
for (int i = 0; i < k; i++) {
SummaryStatistics stats2Gi = m_denStats.get(i);
den += stats2Gi.getSumsq();
}
double L = (m_lstats.getN() - k) / (double) (k - 1) * num / den;
long df1 = k - 1;
long df2 = m_lstats.getN() - k;
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);
}
use of org.knime.core.data.def.IntCell in project knime-core by knime.
the class OneWayANOVAStatistics method getWithinGroups.
/**
* Get the row of the ANOVA table with the cells "Within Groups".
*/
private List<DataCell> getWithinGroups(final ANOVA anova) {
List<DataCell> cells = new ArrayList<DataCell>();
cells.add(new StringCell(m_column));
cells.add(new StringCell(SOURCE_WITHIN_GROUPS));
cells.add(new DoubleCell(anova.getSquri()));
cells.add(new IntCell((int) anova.getDfi()));
cells.add(new DoubleCell(anova.getMsquri()));
cells.add(DataType.getMissingCell());
cells.add(DataType.getMissingCell());
return cells;
}
use of org.knime.core.data.def.IntCell in project knime-core by knime.
the class OneWayANOVAStatistics method getBetweenGroups.
/**
* Get the row of the ANOVA table with the cells "Between Groups".
*/
private List<DataCell> getBetweenGroups(final ANOVA anova) {
List<DataCell> cells = new ArrayList<DataCell>();
cells.add(new StringCell(m_column));
cells.add(new StringCell(SOURCE_BETWEEN_GROUPS));
cells.add(new DoubleCell(anova.getSqurb()));
cells.add(new IntCell((int) anova.getDfb()));
cells.add(new DoubleCell(anova.getMsqurb()));
cells.add(new DoubleCell(anova.getF()));
cells.add(new DoubleCell(anova.getpValue()));
return cells;
}
use of org.knime.core.data.def.IntCell in project knime-core by knime.
the class PairedTTestStatistics method getDescStats.
/**
* Get descriptive statistics for the given column
* @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(m_pair));
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;
}
use of org.knime.core.data.def.IntCell in project knime-core by knime.
the class ARFFRowIterator method createNewDataCellOfType.
/*
* The function creates a default <code> DataCell </code> of a type
* depending on the <code> type </code> passed in, and initializes the value
* of this data cell from the <code> data </code> string (converting the
* string to the corresponding type). It will create a missing cell and
* print a warning if it couldn't convert the string into the appropreate
* format (to int or double). It throws a <code> IllegalStateException
* </code> if the <code> type </code> passed in is not supported. @param
* type Specifies the type of DataCell that is to be created, supported are
* DoubleCell, IntCell, and StringCell. @param data the string
* representation of the value that will be set in the DataCell created. It
* gets trimmed before it's converted into a number. @param
* createMissingCell If set true the default ' <code> missing </code> '
* value of that cell type will be set indicating that the data in that cell
* was not specified. The <code> data </code> parameter is ignored then.
*
* @return <code> DataCell </code> of the type specified in <code> type
* </code> .
*/
private DataCell createNewDataCellOfType(final DataType type, final String data, final boolean createMissingCell) {
if (type.equals(StringCell.TYPE)) {
if (createMissingCell) {
return DataType.getMissingCell();
} else {
return new StringCell(data);
}
} else if (type.equals(IntCell.TYPE)) {
if (createMissingCell) {
return DataType.getMissingCell();
} else {
try {
int val = Integer.parseInt(data.trim());
return new IntCell(val);
} catch (NumberFormatException nfe) {
if (m_numMsgWrongFormat < MAX_ERR_MSG) {
LOGGER.warn("ARFF reader WARNING: Wrong data " + "format. In line " + m_tokenizer.getLineNumber() + " read '" + data + "' for an integer.");
LOGGER.warn(" Creating missing cell for it.");
m_numMsgWrongFormat++;
}
if (m_numMsgWrongFormat == MAX_ERR_MSG) {
LOGGER.warn(" (last message of " + "this kind.)");
m_numMsgWrongFormat++;
}
return DataType.getMissingCell();
}
}
} else if (type.equals(DoubleCell.TYPE)) {
if (createMissingCell) {
return DataType.getMissingCell();
} else {
try {
double val = Double.parseDouble(data.trim());
return new DoubleCell(val);
} catch (NumberFormatException nfe) {
if (m_numMsgWrongFormat < MAX_ERR_MSG) {
LOGGER.warn("ARFF reader WARNING: Wrong data " + "format. In line " + m_tokenizer.getLineNumber() + " read '" + data + "' for a floating point.");
LOGGER.warn(" Creating missing cell for it.");
m_numMsgWrongFormat++;
}
if (m_numMsgWrongFormat == MAX_ERR_MSG) {
m_numMsgWrongFormat++;
LOGGER.warn(" (last message of this kind.)");
}
return DataType.getMissingCell();
}
}
} else {
throw new IllegalStateException("Cannot create DataCell of type" + type.toString());
}
}
Aggregations