web123456

python standard deviation calculation (std)

() When finding the standard deviation, the default is divided by n, that is, it is biased. The standard deviation method of unbiased sample is to add parameter ddof = 1;
() The default is divided by n-1, which means it is unbiased. If you want to be biased like (), you need to add the parameter ddof=0, that is (ddof=0); the DataFrame describe() contains std();

demo:

>>> a
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> (a, ddof = 1)
3.0276503540974917
>>> (((a - (a)) ** 2).sum() / ( - 1))
3.0276503540974917
>>> (( () * ) / ( - 1))
3.0276503540974917