简单的胖尾登录

时间:2014-02-20 22:34:40

标签: python numpy matplotlib networkx binning

我尝试从Plotting log-binned network degree distributions简化日志分箱 输出显示原始分区和日志分区。然而,后者并没有像预期的那样单调减少,并且与原始偏差很大。 这个问题的最佳解决方案是什么?

import networkx as nx
import matplotlib.pyplot as plt
import numpy as np

m = 3
N = 900

G = nx.barabasi_albert_graph(N, m)

degree_list=nx.degree(G).values()

kmin=min(degree_list)
kmax=max(degree_list)

bins=[float(k-0.5) for k in range(kmin,kmax+2,1)]
density, binedges = np.histogram(degree_list, bins=bins, density=True)
bins = np.delete(bins, -1)

logBins = np.logspace(np.log10(kmin), np.log10(kmax),num=20)
logBinDensity, binedges = np.histogram(degree_list, bins=logBins, density=True)
logBins = np.delete(logBins, -1)

fig = plt.figure()
ax = fig.add_subplot(111)
ax.set_xscale('log')
ax.set_yscale('log')

plt.plot(bins,density,'x',color='black')
plt.plot(logBins,logBinDensity,'x',color='blue')
plt.show()

1 个答案:

答案 0 :(得分:1)

噪声是由于N的小,而小值的偏移是由于logbin宽度小于1。添加

for x in range(len(logBins)):
    logBins[x] = mt.ceil(logBins[x])
相关问题