用(python)Scipy装配一个pareto发行版

我有一个我知道有帕累托分布的数据集。 有人能指出我如何在Scipy中适合这个数据集吗? 我得到了下面的代码运行,但我不知道什么是返回给我(a,b,c)。 另外,获得a,b,c后,如何使用它们计算方差?

import scipy.stats as ss 
import scipy as sp

a,b,c=ss.pareto.fit(data)

这是一个快速写入的版本,从鲁珀特给出的参考页面提供了一些提示。 这在scipy和statsmodels目前正在进行中,并要求MLE提供一些固定或冻结的参数,这些参数仅在中继版本中可用。 参数估计值或其他结果统计数据没有标准错误。

'''estimating pareto with 3 parameters (shape, loc, scale) with nested
minimization, MLE inside minimizing Kolmogorov-Smirnov statistic

running some examples looks good
Author: josef-pktd
'''

import numpy as np
from scipy import stats, optimize
#the following adds my frozen fit method to the distributions
#scipy trunk also has a fit method with some parameters fixed.
import scikits.statsmodels.sandbox.stats.distributions_patch

true = (0.5, 10, 1.)   # try different values
shape, loc, scale = true
rvs = stats.pareto.rvs(shape, loc=loc, scale=scale, size=1000)

rvsmin = rvs.min() #for starting value to fmin


def pareto_ks(loc, rvs):
    est = stats.pareto.fit_fr(rvs, 1., frozen=[np.nan, loc, np.nan])
    args = (est[0], loc, est[1])
    return stats.kstest(rvs,'pareto',args)[0]

locest = optimize.fmin(pareto_ks, rvsmin*0.7, (rvs,))
est = stats.pareto.fit_fr(rvs, 1., frozen=[np.nan, locest, np.nan])
args = (est[0], locest[0], est[1])
print 'estimate'
print args
print 'kstest'
print stats.kstest(rvs,'pareto',args)
print 'estimation error', args - np.array(true)

要非常小心的安装电源法则! 许多报道的权力法律实际上严格遵守权力法。 参见Clauset等。 所有的细节(如果你没有访问期刊,也在arxiv上)。 他们有一个现在链接到Python实现的文章的伴侣网站。 不知道它是否使用Scipy,因为我上次使用它时使用了它的R实现。

链接地址: http://www.djcxy.com/p/46909.html

上一篇: Fitting a pareto distribution with (python) Scipy

下一篇: How to include a external jar in a GWT (Google Web Toolkit) project?