Example usage for org.apache.commons.math3.stat.inference TestUtils pairedTTest

List of usage examples for org.apache.commons.math3.stat.inference TestUtils pairedTTest

Introduction

In this page you can find the example usage for org.apache.commons.math3.stat.inference TestUtils pairedTTest.

Prototype

public static boolean pairedTTest(final double[] sample1, final double[] sample2, final double alpha)
        throws NullArgumentException, NoDataException, DimensionMismatchException, NumberIsTooSmallException,
        OutOfRangeException, MaxCountExceededException 

Source Link

Usage

From source file:iDynoOptimizer.MOEAFramework26.src.org.moeaframework.util.statistics.TwoSampleTTest.java

/**
 * {@inheritDoc}/*w  ww  .j  a  va2 s .c o m*/
 * 
 * @see TestUtils#tTest(double[], double[], double)
 * @see TestUtils#pairedTTest(double[], double[], double)
 */
@Override
public boolean test(double alpha) {
    List<double[]> categories = categorize();

    if (independent) {
        return TestUtils.tTest(categories.get(0), categories.get(1), alpha);
    } else {
        return TestUtils.pairedTTest(categories.get(0), categories.get(1), alpha);
    }
}

From source file:eu.crydee.alignment.aligner.ae.MetricsOneVsOneC.java

@Override
public void collectionProcessComplete() throws AnalysisEngineProcessException {
    try {/* ww  w .  j  a  v  a2s  . co m*/
        String template = IOUtils.toString(getClass()
                .getResourceAsStream("/eu/crydee/alignment/aligner/ae/" + "metrics-one-vs-one-template.html"));
        template = template.replace("@@TITLE@@",
                "Metrics comparator" + LocalDateTime.now().format(DateTimeFormatter.ISO_DATE_TIME));
        template = template.replace("@@LEFTALGO@@", leftAlgoName);
        template = template.replace("@@RIGHTALGO@@", rightAlgoName);
        StringBuilder sb = new StringBuilder();
        sb.append("<table class=\"table table-condensed\">\n").append("            <thead>\n")
                .append("                <tr>\n").append("                    <th>Document\\Metric</th>\n");
        for (String key : keys) {
            sb.append("                    <th colspan=\"2\">").append(methodsMetadata.get(key).getRight())
                    .append("</th>\n");
        }
        sb.append("                <tr>\n").append("            </thead>\n").append("            <tbody>\n")
                .append("                <tr>\n").append("                    <td>\n")
                .append("                        <strong>Total</strong>\n")
                .append("                    </td>\n");
        for (String key : keys) {
            SummaryStatistics ss1 = new SummaryStatistics(), ss2 = new SummaryStatistics();
            List<Pair<Double, Double>> column = results.column(key).values().stream().peek(p -> {
                ss1.addValue(p.getLeft());
                ss2.addValue(p.getRight());
            }).collect(Collectors.toList());
            boolean significant = TestUtils.pairedTTest(column.stream().mapToDouble(p -> p.getLeft()).toArray(),
                    column.stream().mapToDouble(p -> p.getRight()).toArray(), 0.05);
            double mean1 = ss1.getMean(), mean2 = ss2.getMean();
            boolean above = mean1 > mean2;
            String summary1 = String.format("%.3f", mean1) + "<small class=\"text-muted\">" + ""
                    + String.format("%.3f", ss1.getStandardDeviation()) + "</small>",
                    summary2 = String.format("%.3f", mean2) + "<small class=\"text-muted\">" + ""
                            + String.format("%.3f", ss2.getStandardDeviation()) + "</small>";
            sb.append("                    <td class=\"")
                    .append(significant ? (above ? "success" : "danger") : "warning").append("\">")
                    .append(summary1).append("</td>\n");
            sb.append("                    <td class=\"")
                    .append(significant ? (!above ? "success" : "danger") : "warning").append("\">")
                    .append(summary2).append("</td>\n");
        }
        sb.append("                </tr>\n");
        SortedSet<String> rows = new TreeSet<>(results.rowKeySet());
        for (String row : rows) {
            sb.append("                <tr>\n").append("                    <td>").append(row)
                    .append("</td>\n");
            for (String key : keys) {
                Pair<Double, Double> r = results.get(row, key);
                sb.append("                    <td>").append(String.format("%.3f", r.getLeft()))
                        .append("</td>\n").append("                    <td>")
                        .append(String.format("%.3f", r.getRight())).append("</td>\n");

            }
            sb.append("                </tr>\n");
        }
        sb.append("            </tbody>\n").append("        </table>");
        FileUtils.write(new File(htmlFilepath), template.replace("@@TABLE@@", sb.toString()),
                StandardCharsets.UTF_8);
    } catch (IOException ex) {
        logger.error("IO problem with the HTML output.");
        throw new AnalysisEngineProcessException(ex);
    }
}