What is the difference between skew and kurtosis functions in pandas vs. scipy?

前端 未结 1 1542
走了就别回头了
走了就别回头了 2021-02-05 11:01

I decided to compare skew and kurtosis functions in pandas and scipy.stats, and don\'t understand why I\'m getting different results between libraries.

As far as I can t

1条回答
  •  失恋的感觉
    2021-02-05 11:48

    The difference is due to different normalizations. Scipy by default does not correct for bias, whereas pandas does.

    You can tell scipy to correct for bias by passing the bias=False argument:

    >>> x = pandas.Series(np.random.randn(10))
    >>> stats.skew(x)
    -0.17644348972413657
    >>> x.skew()
    -0.20923623968879457
    >>> stats.skew(x, bias=False)
    -0.2092362396887948
    >>> stats.kurtosis(x)
    0.6362620964462327
    >>> x.kurtosis()
    2.0891062062174464
    >>> stats.kurtosis(x, bias=False)
    2.089106206217446
    

    There does not appear to be a way to tell pandas to remove the bias correction.

    0 讨论(0)
提交回复
热议问题