Problems with skewness and kurtosis (but not mean and variance)

I am using the package OnlineStats (I am open to suggested other packages) to compute the mean, variance, skewness, and kurtosis of data.

The data is Array{Float64,1}.

The following works fine:

mean(data)
var(data)

but skewness and kurtosis throws an error:

skewness(data)
kurtosis(data)

The error I get is:

**MethodError: objects of type Array{Float64,2} are not callable**

**Use square brackets [] for indexing an Array.**

in top-level scope at [untitled:38](#)

Note that data is free from NaN.

What am I doing wrong?

skewness and kurtosis aren’t called on the data (array) directly. You have to fit! a statistical model at first:
https://joshday.github.io/OnlineStats.jl/stable/stats_and_models/#Univariate-Statistics-1

julia> data=randn(1000);

julia> mean(data)
-0.029101214826974715

julia> var(data)
0.9627532944591485

julia> o = fit!(Moments(),data)
Moments: n=1000 | value=[-0.0291012, 0.962637, -0.073216, 2.84648]

julia> mean(o)
-0.029101214826974704

julia> var(o)
0.9627532944591476

julia> std(o)
0.9811999258352742

julia> skewness(o)
0.011425034687808195

julia> kurtosis(o)
0.07320689858578566
3 Likes