15.08.2015 Views

Introduction to the Modeling and Analysis of Complex Systems

introduction-to-the-modeling-and-analysis-of-complex-systems-sayama-pdf

introduction-to-the-modeling-and-analysis-of-complex-systems-sayama-pdf

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

17.5. DEGREE DISTRIBUTION 395logkdata = []logFdata = []prevF = ccdf[0]for k in domain:F = ccdf[k]if F != prevF:logkdata.append(log(k))logFdata.append(log(F))prevF = Fa, b, r, p, err = st.linregress(logkdata, logFdata)print ’Estimated CCDF: F(k) =’, exp(b), ’* k^’, aprint ’r =’, rprint ’p-value =’, pplot(logkdata, logFdata, ’o’)kmin, kmax = xlim()plot([kmin, kmax],[a * kmin + b, a * kmax + b])xlabel(’log k’)ylabel(’log F(k)’)show()In <strong>the</strong> second code block, <strong>the</strong> domain <strong>and</strong> ccdf were converted <strong>to</strong> log scales for linearfitting. Also, note that <strong>the</strong> original ccdf contained values for all k’s, even for those forwhich P (k) = 0. This would cause unnecessary biases in <strong>the</strong> linear regression <strong>to</strong>ward <strong>the</strong>higher k end where actual samples were very sparse. To avoid this, only <strong>the</strong> data pointswhere <strong>the</strong> value <strong>of</strong> F changed (i.e., where <strong>the</strong>re were actual nodes with degree k) arecollected in <strong>the</strong> logkdata <strong>and</strong> logFdata lists.The result is shown in Fig. 17.11, <strong>and</strong> also <strong>the</strong> following output comes out <strong>to</strong> <strong>the</strong>terminal, which indicates that this was a pretty good fit:Code 17.18:Estimated CCDF: F(k) = 27.7963518947 * k^ -1.97465957944r = -0.997324657337p-value = 8.16476416778e-127

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!