コード例 #1
0
def sim_and_plot(G, tau, gamma, rho, tmax, tcount, ax):
    t, S, I = EoN.fast_SIS(G, tau, gamma, rho=rho, tmax = tmax)
    report_times = scipy.linspace(0, tmax, tcount)
    I = EoN.subsample(report_times, t, I)
    ax.plot(report_times, I/N, color='grey', linewidth=5, alpha=0.3)
    
    t, S, I, = EoN.SIS_heterogeneous_meanfield_from_graph(G, tau, gamma, rho=rho, 
                                                    tmax=tmax, tcount=tcount)
    ax.plot(t, I/N, '--')    
    t, S, I = EoN.SIS_compact_pairwise_from_graph(G, tau, gamma, rho=rho,
                                                    tmax=tmax, tcount=tcount)
    ax.plot(t, I/N)
 
    t, S, I = EoN.SIS_homogeneous_pairwise_from_graph(G, tau, gamma, rho=rho, 
                                                    tmax=tmax, tcount=tcount)
    ax.plot(t, I/N, '-.')
コード例 #2
0
                                                  tau,
                                                  gamma,
                                                  rho=rho,
                                                  tmax=tmax)
plt.plot(t, I, '-.', label='Homogeneous pairwise', linewidth=5)

t, S, I = EoN.SIS_heterogeneous_meanfield_from_graph(G,
                                                     tau,
                                                     gamma,
                                                     rho=rho,
                                                     tmax=tmax)
plt.plot(t, I, ':', label='Heterogeneous meanfield', linewidth=5)

t, S, I = EoN.SIS_compact_pairwise_from_graph(G,
                                              tau,
                                              gamma,
                                              rho=rho,
                                              tmax=tmax)
plt.plot(t, I, '--', label='Compact pairwise', linewidth=5)

plt.xlabel('$t$')
plt.ylabel('Number infected')
plt.legend()

#plt.savefig('SIS_BA_model_vs_sim.png')

# In[11]:

# Which model is better?
for counter in range(iterations):
    t, S, I = EoN.fast_SIS(G, tau, gamma, rho=rho, tmax=tmax)