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;
}