估计幂律分布中的指数截止
当我进行一些社交网络分析时,我偶然发现了在网络度上拟合概率分布的问题。
因此,我有一个概率分布 P(X >= x)
,从目视检查来看,它遵循具有指数截止的幂律,而不是纯幂律(直线)。
因此,假设具有指数截止的幂律分布方程为:
f(x) = x**alpha * exp(beta*x)
如何使用 Python 估计参数 alpha
和 beta
?
我知道 scipy.stats.powerlaw 包存在,并且它们有一个 .fit() 函数,但这似乎不起作用,因为它只返回绘图的位置和比例,这似乎仅对正态分布有用吗?这个包上也没有足够的教程。
PS 我很清楚 CLauset 等人 的实现,但他们不知道似乎提供了估计替代分布参数的方法。
As I have been doing some social network analysis, I have stumbled upon the problem of fitting a probability distribution on network degree.
So, I have a probability distribution P(X >= x)
which, from visual inspection, follows a power law with an exponential cutoff rather than a pure power law (a straight line).
So, given that the equation for power law distribution with exponential cutoff is:
f(x) = x**alpha * exp(beta*x)
How might I estimate the parameters alpha
and beta
using Python?
I know scipy.stats.powerlaw package exists and they have a .fit()
function but that doesn't seem to do the job as it only returns the location and scale of the plot, which seems to be useful only for normal distribution? There are also not enough tutorials on this package.
P.S. I'm well aware of the implementation of CLauset et al but they don't seem to provide ways to estimate the parameters of alternate distributions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Powerlaw库可以直接用于估计参数,如下:
安装所有python依赖项:
在 python 环境中运行 powerlaw 包:
从结果中获取参数
Powerlaw library can directly be used to estimate the parameters as follows:
Install all the pythons dependencies:
Run the powerlaw package fit in a python environment:
get the parameters from the results
函数 scipy.stats.powerlaw.fit 可能仍然适用于您的目的。 scipy.stats 中的分布如何工作有点令人困惑(每个分布的文档都引用了可选参数 loc 和 scale,尽管并非所有分布都使用这些参数,并且每个分布的使用方式都不同)。如果您查看文档:
http://docs。 scipy.org/doc/scipy/reference/ generated/scipy.stats.powerlaw.html
还有第二个非可选参数“a”,即“形状参数”。在幂律的情况下,它包含单个参数。不用担心“loc”和“scale”。
编辑:抱歉,忘记了您也想要 beta 参数。最好的方法可能是自己定义所需的幂律函数,然后使用 scipy 的通用拟合算法来学习参数。例如:
http://www.scipy.org/Cookbook/FittingData#head-5eba0779a34c07f5a596bbcf99dbc7886eac18e5
The function scipy.stats.powerlaw.fit may still work for your purposes. It's a bit confusing how the distributions in scipy.stats work (the documentation for each one refers to the optional parameters loc and scale, even though not all of them use these parameters, and each uses them differently). If you look at the docs:
http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.powerlaw.html
there's also a second non-optional parameter "a", which is the "shape parameters". In the case of powerlaw, this contains a single parameter. Don't worry about "loc" and "scale".
Edit: Sorry, forgot that you wanted the beta parameter too. Your best best may be to define the powerlaw function you want yourself, and then use scipy's generic fitting algorithms to learn the parameters. For example:
http://www.scipy.org/Cookbook/FittingData#head-5eba0779a34c07f5a596bbcf99dbc7886eac18e5
以下是通过最大化 R 中的可能性来估计具有指数截止的幂律的标度指数和指数率的方法:
查看 https://github.com/jeffalstott/powerlaw/ 了解更多信息
Here is a means of estimating the scaling exponent and exponential rate of power law with exponential cut-off by maximizing likelihood in R:
Check out https://github.com/jeffalstott/powerlaw/ for more info