将峰度应用于python中的发行版 [英] Apply kurtosis to a distribution in python

查看:100
本文介绍了将峰度应用于python中的发行版的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据集,格式为



频率,方向,归一化功率谱密度,扩展,偏度,峰度



我可以使用倾斜的正态分布中的顶部答案中的代码来可视化特定记录的分布scipy ,但是我不确定如何将峰度值应用于分布吗?

$ s $$$$$$$$$$$$$ $ b从scipy import pi,sqrt,exp
从scipy.special import erf
从pylab import plot,显示

def pdf(x,factor):
return(100 * factor)/ sqrt(2 * pi)* exp(-x ** 2/2)

def cdf(x):
return(1 + erf(x / sqrt(2)))/ 2

def skew(x,e = 0,w = 1,a = 0,norm_psd = 1):
t =(xe)/ w
return 2 / w * pdf(norm_psd,t)* cdf(a * t)

n = 540
e = 341.9#方向
w = 59.3#价差
a = 3.3#歪斜
k = 4.27#峰度
n_psd = 0.5#归一化po光谱密度
x =线性空间(-90,450,n)


p =歪斜(x,e,w,a,n_psd)
print max(p )
图(x,p)
show()

编辑:我从标题中删除了偏斜法线,因为我认为实际上不可能将峰度值应用于上述分布,我认为有必要使用其他分布,因为方向涉及循环统计中的分布也许更合适?



感谢下面的回答,我可以使用下面代码中演示的pdf_mvsk函数应用峰度,不幸的是,我的偏斜值导致y值为负,但是答案满足了我的问题。

  import numpy as np 
import matplotlib.pyplot as plt
import statsmodels .sandbox.distributions.extras as extras

pdffunc = extras.pdf_mvsk([341.9,59.3,3.3,4.27])
range = np.arange(0,360,0.1)
plt.plot(范围,pdffunc(范围))
plt.show()


解决方案

如果您具有均值,标准差,偏斜和峰度,则可以使用Gram- Charlier扩展。



我前一段时间对此进行了调查,scipy.stats的函数有误,已被删除。



我不记得它的状态是什么,因为很久以前我把它放在statsmodels沙箱
http://statsmodels.sourceforge.net/devel/generation/statsmodels.sandbox。 distributions.extras.pdf_mvsk.html#statsmodels.sandbox.distributions.extras.pdf_mvsk


I have a dataset which is in the format of

frequency, direction, normalised power spectral density, spread, skewness, kurtosis

I am able to visualise the distribution of a specific record using the code from the top answer in skew normal distribution in scipy but I am not sure how to apply a kurtosis value to a distribution?

from scipy import linspace
from scipy import pi,sqrt,exp
from scipy.special import erf
from pylab import plot,show

def pdf(factor, x):
    return (100*factor)/sqrt(2*pi) * exp(-x**2/2)

def cdf(x):
    return (1 + erf(x/sqrt(2))) / 2

def skew(x,e=0,w=1,a=0, norm_psd=1):
    t = (x-e) / w
    return 2 / w * pdf(norm_psd, t) * cdf(a*t)

n = 540
e = 341.9 # direction
w = 59.3 # spread
a = 3.3 # skew
k = 4.27 # kurtosis
n_psd = 0.5 # normalised power spectral density
x = linspace(-90, 450, n) 


p = skew(x, e, w, a, n_psd)
print max(p)
plot(x,p)
show()

Edit: I removed skew normal from my title as I don't think it is actually possible to apply a kurtosis value to the above distribution, I think a different distribution is necessary, as direction is involved a distribution from circular statistics may be more appropriate?

Thanks to the answer below I can apply kurtosis using the pdf_mvsk function demonstrated in the code below, unfortunately my skew values cause a negative y value, but the answer satisfies my question.

import numpy as np
import matplotlib.pyplot as plt
import statsmodels.sandbox.distributions.extras as extras

pdffunc = extras.pdf_mvsk([341.9, 59.3, 3.3, 4.27])
range = np.arange(0, 360, 0.1)
plt.plot(range, pdffunc(range))
plt.show()

解决方案

If you have mean, standard deviation, skew and kurtosis, then you can build an approximately normal distribution with those moments using Gram-Charlier expansion.

I looked into this some time ago, scipy.stats had a function that was wrong and was removed.

I don't remember what the status of this is, since it was a long time ago that I put this in the statsmodels sandbox http://statsmodels.sourceforge.net/devel/generated/statsmodels.sandbox.distributions.extras.pdf_mvsk.html#statsmodels.sandbox.distributions.extras.pdf_mvsk

这篇关于将峰度应用于python中的发行版的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆