【发布时间】:2018-02-10 00:51:18
【问题描述】:
我有一个图表,我计算了度数分布和度数如下:
library(igraph) # for these two functions
dd <- degree_distribution(graph)
d <- degree(graph)
由此,我估计了幂律,看看我的分布是否遵循“幂律”:
degree = 1:max(d)
probability = dd[-1]
nonzero.position = which(probability != 0)
probability = probability[nonzero.position]
degree = degree[nonzero.position]
reg = lm(log(probability) ~ log(degree))
cozf = coef(reg)
power.law.fit = function(x) exp(cozf[[1]] + cozf[[2]] * log(x))
由此,我使用ggplot2 绘制了点和幂律。
结果如下图:
df <- data.frame(x = degree, y = probability)
print(
ggplot(df, aes(x,y,colour="Distribuição"))+
geom_point(shape = 4) +
stat_function(fun = power.law.fit, geom = "line", aes(colour="Power Law"))+
labs(title = "Grafo", subtitle = "Distribuição dos Graus",
x="K", y="P(k)", colour="Legenda")+
scale_color_brewer(palette="Dark2")
)
如您所见,我的分布不遵循幂律!我想估计泊松分布并绘制在同一张图上。 尽管我不确定我的分布不遵循(或遵循)泊松,但我想将它与幂律一起绘制。我不知道如何从数据中估计这个分布(泊松),并计算平均度数。
谁能帮帮我?
用于计算分布和度数的图非常大(70万个顶点),所以我没有放图的数据。答案的解释可以基于任何图表。
【问题讨论】:
-
您可能希望参考 Cross Validated 中关于将分布拟合到 R 中的数据的这些答案:stats.stackexchange.com/questions/51470/…、stats.stackexchange.com/questions/132652/…
-
好答案!我去看看!
标签: r distribution