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

**URL:** <https://discourse.julialang.org/t/problems-with-skewness-and-kurtosis-but-not-mean-and-variance/42466>\
**Category:** New to Julia\
**Created:** [July 3, 2020, 10:06am UTC](https://discourse.julialang.org/t/problems-with-skewness-and-kurtosis-but-not-mean-and-variance/42466 "2020-07-03T10:06:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nash](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nash/32/14482_2.png) [@Nash](https://discourse.julialang.org/u/Nash)\
**Post date:** [July 3, 2020, 10:06am UTC](https://discourse.julialang.org/t/problems-with-skewness-and-kurtosis-but-not-mean-and-variance/42466/1 "2020-07-03T10:06:08Z")

</div>

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:

```julia
mean(data)
var(data)

```

but skewness and kurtosis throws an error:

```julia
skewness(data)
kurtosis(data)

```

The error I get is:

```julia
**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?

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [July 3, 2020, 10:39am UTC](https://discourse.julialang.org/t/problems-with-skewness-and-kurtosis-but-not-mean-and-variance/42466/2 "2020-07-03T10:39:41Z")

</div>

`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](https://joshday.github.io/OnlineStats.jl/stable/stats_and_models/#Univariate-Statistics-1)

```julia
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

```
