# EoN.basic_discrete_SIR¶

EoN.basic_discrete_SIR(G, p, initial_infecteds=None, initial_recovereds=None, rho=None, tmin=0, tmax=inf, return_full_data=False, sim_kwargs=None)[source]

Performs simple discrete SIR simulation assuming constant transmission probability p.

From figure 6.8 of Kiss, Miller, & Simon. Please cite the book if using this algorithm.

Does a simulation of the simple case of all nodes transmitting with probability p independently to each neighbor and then recovering.

G networkx Graph
The network the disease will transmit through.
p number
transmission probability
initial_infecteds node or iterable of nodes (default None)
if a single node, then this node is initially infected if an iterable, then whole set is initially infected if None, then choose randomly based on rho. If rho is also None, a random single node is chosen. If both initial_infecteds and rho are assigned, then there is an error.
initial_recovereds as for initial_infecteds, but for initially
recovered nodes.
rho number (default None)

initial fraction infected. number initially infected is int(round(G.order()*rho))

The default results in a single randomly chosen initial infection.

tmin float (default 0)
start time
tmax float (default infinity)
stop time (if not extinct first).
return_full_data boolean (default False)
Tells whether a Simulation_Investigation object should be returned.
sim_kwargs keyword arguments
Any keyword arguments to be sent to the Simulation_Investigation object Only relevant if return_full_data=True

if return_full_data is False returns

t, S, I, R numpy arrays

these numpy arrays give all the times observed and the number in each state at each time.

Or if return_full_data is True returns

full_data Simulation_Investigation object

from this we can extract the status history of all nodes We can also plot the network at given times and even create animations using class methods.

import networkx as nx
import EoN
import matplotlib.pyplot as plt
G = nx.fast_gnp_random_graph(1000,0.002)
t, S, I, R = EoN.basic_discrete_SIR(G, 0.6)
plt.plot(t,S)

#This sample may be boring if the randomly chosen initial infection
#doesn't trigger an epidemic.