【发布时间】:2020-12-03 00:28:01
【问题描述】:
我想实现图表的累积分布。这是我的代码:
g = nx.read_edgelist('graph', create_using= nx.Graph(), nodetype=int)
degree_sequence = sorted([d for n, d in g.degree()], reverse=True) # degree sequence
degreeCount = collections.Counter(degree_sequence)
deg, cnt = zip(*degreeCount.items())
cs = np.cumsum(deg)
plt.loglog(deg, cs, 'bo')
plt.title("Cumulative Distribution plot")
plt.ylabel("Sample with value > Degree")
plt.xlabel("Degree")
plt.show()
要绘制累积图,我知道我必须在 x 轴上有度数,在 y 轴上必须有值 > 度数的样本。使用我的代码的结果如下:
我不确定我是否使用我的代码获得了预期的情节。如果有问题,谁能帮我解释一下?
【问题讨论】:
标签: python numpy networkx distribution