Example usage for org.apache.commons.math.stat.inference TTestImpl tTest

List of usage examples for org.apache.commons.math.stat.inference TTestImpl tTest

Introduction

In this page you can find the example usage for org.apache.commons.math.stat.inference TTestImpl tTest.

Prototype

public double tTest(StatisticalSummary sampleStats1, StatisticalSummary sampleStats2)
        throws IllegalArgumentException, MathException 

Source Link

Document

Returns the observed significance level, or p-value, associated with a two-sample, two-tailed t-test comparing the means of the datasets described by two StatisticalSummary instances.

Usage

From source file:guineu.modules.dataanalysis.Ttest.TTestTask.java

public double[] Ttest(int mol) throws IllegalArgumentException, MathException {
    DescriptiveStatistics stats1 = new DescriptiveStatistics();
    DescriptiveStatistics stats2 = new DescriptiveStatistics();
    double[] values = new double[3];
    String parameter1 = "";

    try {//w w w  .j a  v a 2  s .  co  m
        // Determine groups for selected raw data files
        List<String> availableParameterValues = dataset.getParameterAvailableValues(parameter);

        int numberOfGroups = availableParameterValues.size();

        if (numberOfGroups > 1) {
            parameter1 = availableParameterValues.get(0);
            String parameter2 = availableParameterValues.get(1);

            for (String sampleName : dataset.getAllColumnNames()) {
                if (dataset.getParametersValue(sampleName, parameter) != null
                        && dataset.getParametersValue(sampleName, parameter).equals(parameter1)) {
                    try {
                        stats1.addValue((Double) this.dataset.getRow(mol).getPeak(sampleName));
                    } catch (Exception e) {

                    }
                } else if (dataset.getParametersValue(sampleName, parameter) != null
                        && dataset.getParametersValue(sampleName, parameter).equals(parameter2)) {
                    try {
                        stats2.addValue((Double) this.dataset.getRow(mol).getPeak(sampleName));
                    } catch (Exception e) {

                    }
                }
            }
        } else {
            return null;
        }
    } catch (Exception e) {
    }

    TTestImpl ttest = new TTestImpl();
    values[0] = ttest.tTest((StatisticalSummary) stats1, (StatisticalSummary) stats2);
    values[1] = stats1.getMean();
    values[2] = stats2.getMean();
    return values;
}

From source file:net.sf.mzmine.modules.peaklistmethods.dataanalysis.heatmaps.HeatMapTask.java

private String getPvalue(DescriptiveStatistics group1, DescriptiveStatistics group2) {
    TTestImpl ttest = new TTestImpl();
    String sig = "";
    try {/*from w w w. j a v a 2 s . c  om*/
        double pValue = ttest.tTest(group1, group2);
        if (pValue < 0.05) {
            sig = "*";
        }
        if (pValue < 0.01) {
            sig = "**";
        }
        if (pValue < 0.001) {
            sig = "***";
        }

    } catch (IllegalArgumentException ex) {
        sig = "-";

    } catch (MathException ex) {
        sig = "-";
    }
    return sig;
}