根据Wikipedia的描述,
from scipy import linspacefrom scipy import pi,sqrt,expfrom scipy.special import erffrom pylab import plot,showdef pdf(x): return 1/sqrt(2*pi) * exp(-x**2/2)def cdf(x): return (1 + erf(x/sqrt(2))) / 2def skew(x,e=0,w=1,a=0): t = (x-e) / w return 2 / w * pdf(t) * cdf(a*t) # You can of course use the scipy.stats.norm versions # return 2 * norm.pdf(t) * norm.cdf(a*t)n = 2**10e = 1.0 # locationw = 2.0 # scalex = linspace(-10,10,n)for a in range(-3,4): p = skew(x,e,w,a) plot(x,p)show()
如果你想找到一个数据集的使用规模,位置和形状参数
scipy.optimize.leastsq,例如使用
e=1.0,
w=2.0并且
a=1.0,
fzz = skew(x,e,w,a) + norm.rvs(0,0.04,size=n) # fuzzy datadef optm(l,x): return skew(x,l[0],l[1],l[2]) - fzzprint leastsq(optm,[0.5,0.5,0.5],(x,))
应该给你类似的东西,
(array([ 1.05206154, 1.96929465, 0.94590444]), 1)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)