SIR_homogeneous_pairwise_from_graph ( G, tau, gamma, rho = rho, tmax = tmax ) plt. #we expect a homogeneous model to perform poorly because the degree #distribution is very heterogeneous t, S, I, R = EoN. #There are versions of these functions that allow you to specify the #initial conditions rather than starting from a graph. Read in the degree distribution of G #and use rho to initialize the various model equations. plot ( t, I, color = 'k', alpha = 0.3 ) #Now compare with ODE predictions. ![]() plot ( t, I, color = 'k', alpha = 0.3, label = 'Simulation' ) plt. fast_SIR ( G, tau, gamma, rho = rho, tmax = tmax ) if counter = 0 : plt. ![]() ![]() barabasi_albert_graph ( N, 5 ) #create a barabasi-albert graph tmax = 20 iterations = 5 #run 5 simulations tau = 0.1 #transmission rate gamma = 1.0 #recovery rate rho = 0.005 #random fraction initially infected for counter in range ( iterations ): #run simulations t, S, I, R = EoN. Import networkx as nx import matplotlib.pyplot as plt import EoN N = 10 ** 5 G = nx.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |