Search in sources :

Example 1 with Variance

use of org.apache.commons.math.stat.descriptive.moment.Variance in project beast-mcmc by beast-dev.

the class CaseToCaseTreeLikelihood method getSummaryStatistics.

// return an array of the mean, median, variance and standard deviation of the given array
// @todo this is pretty wasteful since it gets called so many times per log entry
public static Double[] getSummaryStatistics(Double[] variable) {
    double[] primitiveVariable = new double[variable.length];
    for (int i = 0; i < variable.length; i++) {
        primitiveVariable[i] = variable[i];
    }
    Double[] out = new Double[4];
    out[0] = (new Mean()).evaluate(primitiveVariable);
    out[1] = (new Median()).evaluate(primitiveVariable);
    out[2] = (new Variance()).evaluate(primitiveVariable);
    out[3] = Math.sqrt(out[2]);
    return out;
}
Also used : Mean(org.apache.commons.math.stat.descriptive.moment.Mean) Median(org.apache.commons.math.stat.descriptive.rank.Median) Variance(org.apache.commons.math.stat.descriptive.moment.Variance)

Aggregations

Mean (org.apache.commons.math.stat.descriptive.moment.Mean)1 Variance (org.apache.commons.math.stat.descriptive.moment.Variance)1 Median (org.apache.commons.math.stat.descriptive.rank.Median)1