在igraph中绘制度分布的幂律拟合图

3
我使用igraph创建了一个有向图,
ba_game_graph <- sample_pa(10000, power = 1, m = NULL, out.dist = NULL, out.seq = NULL,
  out.pref = FALSE, zero.appeal = 1, directed = TRUE,
  algorithm = c("psumtree"), start.graph = NULL)

获取其度数分布

ba_game_deg_dist_tot <- degree_distribution(ba_game_graph, cumulative = FALSE, mode = c("total"))

符合幂律分布

ba_game_plaw <- fit_power_law(ba_game_deg_dist_tot, implementation = c("plfit"), force.continuous = FALSE)

现在我想绘制度分布直方图和幂律曲线。如何进行操作?
hist(ba_game_deg_dist_tot, pch=20, breaks=25, prob=TRUE, main="")
1个回答

0
这是四年后的事情,但我认为这可能是你想要的:
# plot the degree distribution on a log-log plot
plot(ba_game_deg_dist_tot,
     log = "xy",
     xlab = "Node Degree",
     ylab = "Probability")

# add the fitted power law line; the exponent value comes from alpha, part of
# the output of the fit.power.law() function. 
lines(seq(ba_game_deg_dist_tot), 
      seq(ba_game_deg_dist_tot)^-ba_game_plaw$alpha, 
      col="#b00606")

reprex package(v2.0.0)于2022年1月29日创建

根据power.law.fit()函数生成的列表中的p值,该模型是数据的合理拟合。但是,如果我理解正确,您需要将其与其他可能更好的分布的拟合进行比较以确认此点。不确定如何做到这一点 - 但也许这可以让您更接近。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接