简体   繁体   English

使用poweRlaw软件包进行截止配电的Power Law Fit

[英]Power Law Fit of cut-off distribution with the poweRlaw package

I am currently trying to find a way to calculate a power-law fit for a cut-off distribution with MLE. 我目前正在尝试找到一种方法来计算MLE截止分布的幂律。 The distribution looks as follows: 分布如下所示:

此搜索

As you can see, I was able to fit the whole distribution (Power-law fit) and also the lower bound (exp-fit) separately. 如您所见,我能够分别拟合整个分布(幂律拟合)和下限(exp-fit)。 What I am failing to figure out, is how to fit the upper bound of the distribution (fe 8 < x < 100). 我没有弄清楚的是如何拟合分布的上限(fe 8 <x <100)。

Is there any way to do this with the poweRlaw package or any other R package? 使用poweRlaw软件包或任何其他R软件包有什么办法? What I am hoping for is something looking like this (note: it is just a random distribution): 我希望的是这样的东西(注意:这只是一个随机分布):

镜像2

Code (if necessary): 代码(如有必要):

#Power-Law
library("poweRlaw")
xmin1 <- 8
xmin2 <- 100
plf0 <- displ$new(deg)
plf0$setXmin(xmin1)
plf0_pars <- estimate_pars(plf0)
plf0$setPars(plf0_pars)

#Exponential
exp1 <- disexp$new(deg)
exp1$setXmin(xmin2)
exp1_pars <- estimate_pars(exp1)
exp1$setPars(exp1_pars)
plot(plf0)
lines(plf0, col="green")
lines(exp1, col="red")

You can't fit this type of model with the poweRlaw package (I'm the package author). 您无法使用poweRlaw软件包(我是软件包的作者)来适合此类模型。

It's unlikely to be added to the package in the near package. 不太可能将其添加到Near软件包中。

Following solution provides R code that can be run with Python using rpy2 . 以下解决方案提供了可以使用rpy2与Python一起运行的R代码。

It provides instructions based in the source code by powerlaw library, as suggested by the answer by Kelvin , mainly from: https://github.com/jeffalstott/powerlaw/blob/master/testing/pli-R-v0.0.3-2007-07-25/powerexp.R file. 正如Kelvin回答所建议的那样,它根据powerlaw库提供基于源代码的指令,主要来自于: https : //github.com/jeffalstott/powerlaw/blob/master/testing/pli-R-v0.0.3-2007 -07-25 / powerexp.R文件。

  1. Install Gnu Scientific Library (GSL) 安装Gnu科学图书馆(GSL)

    In Debian: apt-get install libgl2 在Debian中: apt-get install libgl2

  2. Download powerlaw python library code from github. 从github下载powerlaw python库代码。
  3. unpack and build exponential-integral.tgz file located at testing/pli-R-v0.0.3-2007-07-25/ folder of the previously downloaded library. 解压缩并构建位于以前下载的库的testing/pli-R-v0.0.3-2007-07-25/文件夹中的exponential-integral.tgz文件。

     tar xzf exponential-integral.tgz cd exponential-integral make 
  4. Move exp_int file to an executable path, named yourexecutablepath from here on. 从此处将exp_int文件移动到名为yourexecutablepath的可执行路径。

    mv exp_int yourexecutablepath

  5. Modify exp_int_function_filename variable from powerexp.R file with the full path to exp_int executable, ie yourexecutablepath/exp_int . 使用具有exp_int可执行文件的完整路径(即yourexecutablepath/exp_int ,修改exp_int_function_filename文件中的exp_int_function_filename变量。

  6. eval exp.R , pareto.R and powerexp.R R source code to include all the needed functions. eval exp.Rpareto.Rpowerexp.R R源代码以包括所有所需的功能。

  7. Fit your data to a powerlaw with exponential cut-off evaluating the following R call: 将数据拟合到幂指数,并通过指数截止来评估以下R调用:

     data <- list(5, 3, ...) powerexp.fit(unlist(data)) 

The output of the last command provides several output values, among them exponent which gives the power law alpha value and rate which gives the exponential cut-off parameter. 最后一条命令的输出提供了几个输出值,其中的exponent给出幂律的alpha值, rate给出指数截止参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM