Power Law适用于PoweRlaw包的截止分配 [英] Power Law Fit of cut-off distribution with the poweRlaw package
问题描述
我目前正试图找到一种方法来计算MLE截断分布的幂律拟合。分发看起来如下:
p>
正如您所看到的,我可以分别拟合整个分布(幂律拟合)和下限(exp-fit)。我无法弄清楚的是如何拟合分布的上限(fe 8 有什么办法可以做这与 poweRlaw 包或任何其他R包?我希望看到的东西是这样的(注意:它只是一个随机分布): 代码p $ lt; code>#Power-Law 以下解决方案提供了可以使用Python运行的R代码: rpy2 。 它通过 Kelvin的回答所建议的那样,主要来自: a href =https://github.com/jeffalstott/powerlaw/blob/master/testing/pli-R-v0.0.3-2007-07-25/powerexp.R =nofollow noreferrer> https:/ /github.com/jeffalstott/powerlaw/blob/master/testing/pli-R-v0.0.3-2007-07-25/powerexp.R 档案。 安装 Gnu科学图书馆(GSL) 解压缩并构建 移动 修改 eval
library(poweRlaw)
xmin1 < - 8
xmin2 < - 100
plf0 < - displ $新(度)
plf0 $ setXmin(xmin1)
plf0_pars< - estimate_pars(plf0)
plf0 $ setPars(plf0_pars)
#Exponential
exp1< - disexp $ new(deg)
exp1 $ setXmin(xmin2)
exp1_pars< - estimated_pars(exp1)
exp1 $ setPars(exp1_pars)
plot(plf0)
lines(plf0,col =green)
lines(exp1,col =red)
$ b 在Debian中: apt-get install libgl2 $> li>从github下载 powerlaw python库代码。
exponential-integral.tgz
位于 testing / pli-R-v0.0.3-2007-07-25 /
以前下载的库的文件夹。
tar xzf exponential-integral.tgz
cd ex $ p
$ / code>
exp_int
文件复制到一个可执行路径,从这里开始,命名为
yourexecutablepath
。
mv exp_int yourexecutablepath
exp_int_function_filename
powerexp.R文件,包含exp_int可执行文件的完整路径,即 yourexecutablepath / exp_int
。
exp.R
, pareto.R
和 powerexp.R
R源代码包含了所有需要的功能。
$ b
data< - list(5,3,...)
powerexp.fit(unlist(data))
最后一个命令的输出提供了几个输出值, code> exponent ,它给出了幂定律 alpha 值和 rate
,它给出了expon ential截止参数。
I am currently trying to find a way to calculate a power-law fit for a cut-off distribution with 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. What I am failing to figure out, is how to fit the upper bound of the distribution (f.e. 8 < x < 100).
Is there any way to do this with the poweRlaw package or any other R package? What I am hoping for is something looking like this (note: it is just a random distribution):
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")
Following solution provides R code that can be run with Python using rpy2.
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.
Install Gnu Scientific Library (GSL)
In Debian:
apt-get install libgl2
- Download powerlaw python library code from github.
unpack and build
exponential-integral.tgz
file located attesting/pli-R-v0.0.3-2007-07-25/
folder of the previously downloaded library.tar xzf exponential-integral.tgz cd exponential-integral make
Move
exp_int
file to an executable path, namedyourexecutablepath
from here on.mv exp_int yourexecutablepath
Modify
exp_int_function_filename
variable from powerexp.R file with the full path to exp_int executable, i.e.yourexecutablepath/exp_int
.eval
exp.R
,pareto.R
andpowerexp.R
R source code to include all the needed functions.Fit your data to a powerlaw with exponential cut-off evaluating the following R call:
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.
这篇关于Power Law适用于PoweRlaw包的截止分配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!