# Package Distributions gives different resullt for standard deviation

**URL:** <https://discourse.julialang.org/t/package-distributions-gives-different-resullt-for-standard-deviation/4135>\
**Category:** General Usage\
**Created:** [June 7, 2017, 1:16pm UTC](https://discourse.julialang.org/t/package-distributions-gives-different-resullt-for-standard-deviation/4135 "2017-06-07T13:16:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![phillefjonk](https://avatars.discourse-cdn.com/v4/letter/p/f04885/32.png) [@phillefjonk](https://discourse.julialang.org/u/phillefjonk)\
**Post date:** [June 7, 2017, 1:16pm UTC](https://discourse.julialang.org/t/package-distributions-gives-different-resullt-for-standard-deviation/4135/1 "2017-06-07T13:16:55Z")

</div>

I am using two methods for computing the standard deviation of a dataset, which gives different results. Why is that so?

1. With the package Distributions function fit()  
and
2. with the ordinary function std()

```julia
# Computing with the fit() function of the Distributions package
println("mean and std dev for x_data: ", fit(data[:,1]))

# Computing with the function std()
println("x_data std dev: ", std(data[:,1]))

```

The result is:

```julia
mean and std dev for x_data: Distributions.Normal{Float64}(μ=32846.249322493226, σ=6.1063435696254835)
x_data std dev: 6.110484867876836

```

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [June 7, 2017, 1:23pm UTC](https://discourse.julialang.org/t/package-distributions-gives-different-resullt-for-standard-deviation/4135/2 "2017-06-07T13:23:54Z")

</div>

I’m not good at statistics but presumably, the fitting for the normal distribution uses Maximum Likelihood Estimation (which uses the unadjusted smaple mean) to estimate the standard deviance while `std` by default uses the _corrected_ sample mean, which divides with `n-1`.

---

<div class="post-metadata">

**Author:** ![Dan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dan/32/42581_2.png) [@Dan](https://discourse.julialang.org/u/Dan)\
**Post date:** [June 7, 2017, 1:44pm UTC](https://discourse.julialang.org/t/package-distributions-gives-different-resullt-for-standard-deviation/4135/3 "2017-06-07T13:44:18Z")

</div>

Most probably @kristoffer.carlsson is right especially if `size(data,1) == 738` 😉

---

<div class="post-metadata">

**Author:** ![Balinus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/balinus/32/243_2.png) [@Balinus](https://discourse.julialang.org/u/Balinus)\
**Post date:** [June 7, 2017, 1:46pm UTC](https://discourse.julialang.org/t/package-distributions-gives-different-resullt-for-standard-deviation/4135/4 "2017-06-07T13:46:25Z")

</div>

Try ?

```julia
std(data[:, 1], corrected = false)

```

edit - deleted.
