Example usage for org.apache.commons.math3.stat.inference OneWayAnova anovaFValue

List of usage examples for org.apache.commons.math3.stat.inference OneWayAnova anovaFValue

Introduction

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

Prototype

public double anovaFValue(final Collection<double[]> categoryData)
        throws NullArgumentException, DimensionMismatchException 

Source Link

Document

Computes the ANOVA F-value for a collection of double[] arrays.

Usage

From source file:org.apache.solr.client.solrj.io.eval.AnovaEvaluator.java

@Override
public Object doWork(Object... values) throws IOException {

    // at this point we know every incoming value is an array of BigDecimals

    List<double[]> anovaInput = Arrays.stream(values)
            // for each List, convert to double[]
            .map(value -> ((List<BigDecimal>) value).stream().mapToDouble(BigDecimal::doubleValue).toArray())
            // turn into List<double[]>
            .collect(Collectors.toList());

    OneWayAnova anova = new OneWayAnova();
    double p = anova.anovaPValue(anovaInput);
    double f = anova.anovaFValue(anovaInput);
    Map<String, Number> m = new HashMap<>();
    m.put("p-value", p);
    m.put("f-ratio", f);
    return new Tuple(m);
}