scipy stats.kurtosistest()函数| Python
scipy.stats.kurtosistest(array, axis=0)
函数测试给定数据集是否具有正常峰度(Fisher 或 Pearson)。
什么是峰态?
它是第四个中心矩除以方差的平方。它是“尾性”的度量,即实值随机变量的概率分布形状的描述符。简单来说,可以说它是衡量尾部与正态分布相比的重度。
它的公式——
Parameters :
array : Input array or object having the elements.
axis : Axis along which the kurtosistest is to be computed. By default axis = 0.
Returns : Z-score (Statistics value) and P-value for the normally distributed data set.
代码#1:
# Graph using numpy.linspace()
# finding kurtosis
from scipy.stats import kurtosistest
import numpy as np
import pylab as p
x1 = np.linspace( -5, 5, 1000 )
y1 = 1./(np.sqrt(2.*np.pi)) * np.exp( -.5*(x1)**2 )
p.plot(x1, y1, '*')
print( '\nKurtosis for normal distribution :\n', kurtosistest(y1))
输出 :
正态分布的峰度:KurtosistestResult(statistic=-2.2557936070461615, pvalue=0.024083559905734513)