I use commons.math3 for calculating some statistical moments, like this:
import org.apache.commons.math3.*;
And in my code:
double beatsdifa[] = new double[beatsdif.size()];
//fill array
query.add(""+ percentile.evaluate(beatsdifa, 80.0));
GeometricMean geoMean = new GeometricMean();
query.add("" + geoMean.evaluate(beatsdifa));
Mean mean2 = new Mean();
query.add("" + mean2.evaluate(beatsdifa));
Variance variance = new Variance();
query.add("" + variance.evaluate(beatsdifa));
StandardDeviation stdDev = new StandardDeviation();
query.add(""+stdDev.evaluate(beatsdifa));
Skewness skewness = new Skewness();
query.add(""+skewness.evaluate(beatsdifa));
Kurtosis kurtosis = new Kurtosis();
query.add(""+kurtosis.evaluate(beatsdifa));
Now I also want to calculate Max, Min and Range.
I tried it like this, but that gives me an error:
Min mix = new Min();
query.add("" + min.evaluate(beatsdifa));
Max max = new Max();
query.add("" + max.evaluate(beatsdifa));
"The method double[] is undefined for max.evaluate."
Sorry to ask this perhaps easy questions, but the commons documentation was not so clear and I did not see an easy way to calculate this. Thanks for helping me out.
The commons library provides to classes named Max
and Min
. Make sure, that you import the correct one, which is
org.apache.commons.math3.stat.descriptive.rank.Max
The other one is
org.apache.commons.math3.analysis.function.Max