문제

I tried to simplify the log-binning from Plotting log-binned network degree distributions The output shows both the original and the log-binned distributions. However, the latter does not decrease monotonically as it is supposed to, and deviates greatly from the original. What is the best solution to this problem?

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()

올바른 솔루션이 없습니다

다른 팁

The noise is due to the smallness of N, while the offset at small values is due to the logbin widths being less than one. Add

for x in range(len(logBins)):
    logBins[x] = mt.ceil(logBins[x])
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top