From the docs of std
:
The algorithm returns an estimator of the generative distribution’s standard deviation under the assumption that each entry of itr is an IID drawn from that generative distribution. For arrays, this computation is equivalent to calculating
sqrt(sum((itr .- mean(itr)).^2) / (length(itr) - 1))
. Ifcorrected
istrue
, then the sum is scaled withn-1
, whereas the sum is scaled withn
if corrected is false withn
the number of elements initr
.
std
by default does a “corrected” standard deviation. This is what you want if the mean of your data is estimated by taking the average of the data. If you know the mean a-priori and subtract it off manually or provide it with the mean
argument, then you should give corrected=false
to std
.
So I think your implementation is doing the right thing and sklearn
is not.