scipy stats.kurtosis()函数| Python
scipy.stats.kurtosis(array, axis=0, fisher=True, bias=True)
函数计算数据集的峰度(Fisher 或 Pearson)。它是第四个中心矩除以方差的平方。它是“尾性”的度量,即实值随机变量的概率分布形状的描述符。简单来说,可以说它是衡量尾部与正态分布相比的重度。
它的公式——
Parameters :
array : Input array or object having the elements.
axis : Axis along which the kurtosis value is to be measured. By default axis = 0.
fisher : Bool; Fisher’s definition is used (normal 0.0) if True; else Pearson’s definition is used (normal 3.0) if set to False.
bias : Bool; calculations are corrected for statistical bias, if set to False.
Returns : Kurtosis value of the normal distribution for the data set.
代码#1:
# Graph using numpy.linspace()
# finding kurtosis
from scipy.stats import kurtosis
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 :', kurtosis(y1))
print( '\nKurtosis for normal distribution :',
kurtosis(y1, fisher = False))
print( '\nKurtosis for normal distribution :',
kurtosis(y1, fisher = True))
输出 :
正态分布峰度:-0.3073930877422071 正态分布峰度:2.692606912257793 正态分布峰度:-0.3073930877422071