dorien
dorien

Reputation: 5387

Calculating Skewness and kurtosis with apache commons

I have datapoints in a vector and I would like to calculate the skewness and kurtosis of the dataset.

How do I go about this with apache commons?

Vector<Double> mydata = new Vector<Double>
//data points are added by my routing

The code I found in the documentation goes like this:

    FourthMoment m4 = new FourthMoment();
    Mean m = new Mean(m4);
    Variance v = new Variance(m4);
    Skewness s= new Skewness(m4);
    Kurtosis k = new Kurtosis(m4);
    assertEquals(var,v.getResult(),tolerance);
    assertEquals(skew ,s.getResult(),tolerance);

But Fourthmoment is not recognised by my compiler. And how do I actually get the mydata in there?

Thanks for any help, I can not seem to get clear examples.

I use version 3.1.1 and it recognises all my imports, except the first one:

import org.apache.commons.math3.stat.descriptive.moment.FourthMoment;
import org.apache.commons.math3.stat.descriptive.moment.Kurtosis;
import org.apache.commons.math3.stat.descriptive.moment.Mean;
import org.apache.commons.math3.stat.descriptive.moment.Skewness;
import org.apache.commons.math3.stat.descriptive.moment.Variance;

Upvotes: 3

Views: 3431

Answers (1)

NPE
NPE

Reputation: 500247

do I need this fourth moment? Or can I just calculate it based on my vector?

I think you can calculate it directly, using Kurtosis.evaluate().

Upvotes: 3

Related Questions