Different std in pandas vs numpy

前端 未结 2 2047
醉话见心
醉话见心 2020-12-08 19:21

The standard deviation differs between pandas and numpy. Why and which one is the correct one? (the relative difference is 3.5% which should not come from rounding, this is

2条回答
  •  孤街浪徒
    2020-12-08 19:52

    In a nutshell, neither is "incorrect". Pandas uses the unbiased estimator (N-1 in the denominator), whereas Numpy by default does not.

    To make them behave the same, pass ddof=1 to numpy.std().

    For further discussion, see

    • Can someone explain biased/unbiased population/sample standard deviation?
    • Population variance and sample variance.
    • Why divide by n-1?

提交回复
热议问题