Package Distributions gives different resullt for standard deviation


#1

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()
# 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:

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

#2

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.


#3

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


#4

Try ?

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

edit - deleted.