2

So I've been playing around with Julia, and I've discovered that the function to calculate the kurtosis of a probability distribution is implemented differently between Julia and MATLAB.

In Julia, do:

using Distributions
dist = Beta(3, 5)
x = rand(dist, 10000)
kurtosis(x) #gives a value approximately around -0.42

In MATLAB do:

x = betarnd(3, 5, [1, 10000]);
kurtosis(x) %gives something approximately around 2.60

What's happening here? Why is the kurtosis different between the two languages?

Hasnain Raza
  • 681
  • 5
  • 10
  • 5
    The Kurtosis of the Normal distribution is 3. So 3 is often subtracted from the calculated Kurtosis, and then it is sometimes called the *Excess Kurtosis*. My guess, is Julia is calculating the Excess Kurtosis. – Dan Getz Jan 03 '17 at 14:17
  • 1
    @DanGetz you are correct, [per Julia's documentation](http://distributionsjl.readthedocs.io/en/latest/univariate.html#kurtosis) – sco1 Jan 03 '17 at 14:21
  • 3
    The documentation on MATLAB's [kurtosis](http://mathworks.com/help/stats/kurtosis.html) show you exactly what that calculates. – Adriaan Jan 03 '17 at 14:21

1 Answers1

5

As explained here: http://www.itl.nist.gov/div898/handbook/eda/section3/eda35b.htm

We often use excess Kurtosis (Kurtosis - 3) so that the (Excess) Kurtosis of a normal distribution becomes zero. As shown in the distributions.jl docs that is what is used by kurtosis(x) in Julia.

Matlab does not use the excess measure (there is even a note in the docs that mentions this potential issue).

Alexander Morley
  • 4,111
  • 12
  • 26