Figure 6.24 --------------------------- :download:`Downloadable Source Code ` .. image:: fig6p24.png :: import networkx as nx import EoN from collections import defaultdict import matplotlib.pyplot as plt import scipy import random colors = ['#5AB3E6','#FF2000','#009A80','#E69A00', '#CD9AB3', '#0073B3','#F0E442'] rho = 0.01 Nbig=500000 Nsmall = 5000 tau =0.4 gamma = 1. def poisson(): return scipy.random.poisson(5) def PsiPoisson(x): return scipy.exp(-5*(1-x)) def DPsiPoisson(x): return 5*scipy.exp(-5*(1-x)) bimodalPk = {8:0.5, 2:0.5} def PsiBimodal(x): return (x**8 +x**2)/2. def DPsiBimodal(x): return(8*x**7 + 2*x)/2. def homogeneous(): return 5 def PsiHomogeneous(x): return x**5 def DPsiHomogeneous(x): return 5*x**4 PlPk = {} exponent = 1.418184432 kave = 0 for k in range(1,81): PlPk[k]=k**(-exponent)*scipy.exp(-k*1./40) kave += k*PlPk[k] normfact= sum(PlPk.values()) for k in PlPk: PlPk[k] /= normfact #def trunc_pow_law(): # r = random.random() # for k in PlPk: # r -= PlPk[k] # if r<0: # return k def PsiPowLaw(x): #print PlPk rval = 0 for k in PlPk: rval += PlPk[k]*x**k return rval def DPsiPowLaw(x): rval = 0 for k in PlPk: rval += k*PlPk[k]*x**(k-1) return rval def get_G(N, Pk): while True: ks = [] for ctr in range(N): r = random.random() for k in Pk: if r