hypercontagion.sim.epidemics
Classic epidemiological models extended to higher-order contagion.
Functions
- hypercontagion.sim.epidemics.discrete_SIR(H, tau, gamma, transmission_function=<function threshold>, initial_infecteds=None, initial_recovereds=None, recovery_weight=None, transmission_weight=None, rho=None, tmin=0, tmax=inf, dt=1.0, return_event_data=False, seed=None, **args)[source]
Simulates the discrete SIR model for hypergraphs.
- Parameters
H (xgi.Hypergraph) – The hypergraph on which to simulate the SIR contagion process
tau (dict) – Keys are edge sizes and values are transmission rates
gamma (float) – Healing rate
transmission_function (lambda function, default: threshold) – The contagion function that determines whether transmission is possible.
initial_infecteds (iterable, default: None) – Initially infected node IDs.
initial_recovereds (iterable, default: None) – Initially recovered node IDs.
recovery_weight (hashable, default: None) – Hypergraph node attribute that weights the healing rate.
transmission_weight (hashable, default: None) – Hypergraph edge attribute that weights the transmission rate.
rho (float, default: None) – Fraction initially infected. Cannot be specified if initial_infecteds is defined.
tmin (float, default: 0) – Time at which the simulation starts.
tmax (float, default: float("Inf")) – Time at which the simulation terminates if there are still infected nodes.
dt (float, default: 1.0) – The time step of the simulation.
return_event_data (bool, default: False) – Whether to track each individual transition event that occurs.
seed (integer, random_state, or None (default)) – Indicator of random number generation state.
- Returns
t, S, I, R
- Return type
tuple of np.arrays
- Raises
HyperContagionError – If the user specifies both rho and initial_infecteds.
- hypercontagion.sim.epidemics.discrete_SIS(H, tau, gamma, transmission_function=<function threshold>, initial_infecteds=None, recovery_weight=None, transmission_weight=None, rho=None, tmin=0, tmax=inf, dt=1.0, return_event_data=False, seed=None, **args)[source]
Simulates the discrete SIS model for hypergraphs.
- Parameters
H (xgi.Hypergraph) – The hypergraph on which to simulate the SIR contagion process
tau (dict) – Keys are edge sizes and values are transmission rates
gamma (float) – Healing rate
transmission_function (lambda function, default: threshold) – The contagion function that determines whether transmission is possible.
initial_infecteds (iterable, default: None) – Initially infected node IDs.
initial_recovereds (iterable, default: None) – Initially recovered node IDs.
recovery_weight (hashable, default: None) – Hypergraph node attribute that weights the healing rate.
transmission_weight (hashable, default: None) – Hypergraph edge attribute that weights the transmission rate.
rho (float, default: None) – Fraction initially infected. Cannot be specified if initial_infecteds is defined.
tmin (float, default: 0) – Time at which the simulation starts.
tmax (float, default: float("Inf")) – Time at which the simulation terminates if there are still infected nodes.
dt (float, default: 1.0) – The time step of the simulation.
return_event_data (bool, default: False) – Whether to track each individual transition event that occurs.
seed (integer, random_state, or None (default)) – Indicator of random number generation state.
- Returns
t, S, I
- Return type
tuple of np.arrays
- Raises
HyperContagionError – If the user specifies both rho and initial_infecteds.
- hypercontagion.sim.epidemics.Gillespie_SIR(H, tau, gamma, transmission_function=<function threshold>, initial_infecteds=None, initial_recovereds=None, rho=None, tmin=0, tmax=inf, recovery_weight=None, transmission_weight=None, return_event_data=False, seed=None, **args)[source]
Simulates the SIR model for hypergraphs with the Gillespie algorithm.
- Parameters
H (xgi.Hypergraph) – The hypergraph on which to simulate the SIR contagion process
tau (dict) – Keys are edge sizes and values are transmission rates
gamma (float) – Healing rate
transmission_function (lambda function, default: threshold) – The contagion function that determines whether transmission is possible.
initial_infecteds (iterable, default: None) – Initially infected node IDs.
initial_recovereds (iterable, default: None) – Initially recovered node IDs.
recovery_weight (hashable, default: None) – Hypergraph node attribute that weights the healing rate.
transmission_weight (hashable, default: None) – Hypergraph edge attribute that weights the transmission rate.
rho (float, default: None) – Fraction initially infected. Cannot be specified if initial_infecteds is defined.
tmin (float, default: 0) – Time at which the simulation starts.
tmax (float, default: float("Inf")) – Time at which the simulation terminates if there are still infected nodes.
return_event_data (bool, default: False) – Whether to track each individual transition event that occurs.
seed (integer, random_state, or None (default)) – Indicator of random number generation state.
- Returns
t, S, I, R
- Return type
tuple of np.arrays
- Raises
HyperContagionError – If the user specifies both rho and initial_infecteds.
- hypercontagion.sim.epidemics.Gillespie_SIS(H, tau, gamma, transmission_function=<function threshold>, initial_infecteds=None, rho=None, tmin=0, tmax=100, recovery_weight=None, transmission_weight=None, return_event_data=False, seed=None, **args)[source]
Simulates the SIS model for hypergraphs with the Gillespie algorithm.
- Parameters
H (xgi.Hypergraph) – The hypergraph on which to simulate the SIR contagion process
tau (dict) – Keys are edge sizes and values are transmission rates
gamma (float) – Healing rate
transmission_function (lambda function, default: threshold) – The contagion function that determines whether transmission is possible.
initial_infecteds (iterable, default: None) – Initially infected node IDs.
initial_recovereds (iterable, default: None) – Initially recovered node IDs.
recovery_weight (hashable, default: None) – Hypergraph node attribute that weights the healing rate.
transmission_weight (hashable, default: None) – Hypergraph edge attribute that weights the transmission rate.
rho (float, default: None) – Fraction initially infected. Cannot be specified if initial_infecteds is defined.
tmin (float, default: 0) – Time at which the simulation starts.
tmax (float, default: float("Inf")) – Time at which the simulation terminates if there are still infected nodes.
return_event_data (bool, default: False) – Whether to track each individual transition event that occurs.
seed (integer, random_state, or None (default)) – Indicator of random number generation state.
- Returns
t, S, I
- Return type
tuple of np.arrays
- Raises
HyperContagionError – If the user specifies both rho and initial_infecteds.
- hypercontagion.sim.epidemics.event_driven_SIR(H, tau, gamma, transmission_function=<function majority_vote>, initial_infecteds=None, initial_recovereds=None, rho=None, tmin=0, tmax=inf, return_event_data=False, seed=None, **args)[source]
Simulates the SIR model for hypergraphs with the event-driven algorithm.
- Parameters
H (xgi.Hypergraph) – The hypergraph on which to simulate the SIR contagion process
tau (dict) – Keys are edge sizes and values are transmission rates
gamma (float) – Healing rate
transmission_function (lambda function, default: threshold) – The contagion function that determines whether transmission is possible.
initial_infecteds (iterable, default: None) – Initially infected node IDs.
initial_recovereds (iterable, default: None) – Initially recovered node IDs.
recovery_weight (hashable, default: None) – Hypergraph node attribute that weights the healing rate.
transmission_weight (hashable, default: None) – Hypergraph edge attribute that weights the transmission rate.
rho (float, default: None) – Fraction initially infected. Cannot be specified if initial_infecteds is defined.
tmin (float, default: 0) – Time at which the simulation starts.
tmax (float, default: float("Inf")) – Time at which the simulation terminates if there are still infected nodes.
return_event_data (bool, default: False) – Whether to track each individual transition event that occurs.
- Returns
t, S, I, R
- Return type
tuple of np.arrays
- Raises
HyperContagionError – If the user specifies both rho and initial_infecteds.
- hypercontagion.sim.epidemics.event_driven_SIS(H, tau, gamma, transmission_function=<function majority_vote>, initial_infecteds=None, rho=None, tmin=0, tmax=inf, return_event_data=False, seed=None, **args)[source]
Simulates the SIS model for hypergraphs with the event-driven algorithm.
- Parameters
H (xgi.Hypergraph) – The hypergraph on which to simulate the SIR contagion process
tau (dict) – Keys are edge sizes and values are transmission rates
gamma (float) – Healing rate
transmission_function (lambda function, default: threshold) – The contagion function that determines whether transmission is possible.
initial_infecteds (iterable, default: None) – Initially infected node IDs.
initial_recovereds (iterable, default: None) – Initially recovered node IDs.
recovery_weight (hashable, default: None) – Hypergraph node attribute that weights the healing rate.
transmission_weight (hashable, default: None) – Hypergraph edge attribute that weights the transmission rate.
rho (float, default: None) – Fraction initially infected. Cannot be specified if initial_infecteds is defined.
tmin (float, default: 0) – Time at which the simulation starts.
tmax (float, default: float("Inf")) – Time at which the simulation terminates if there are still infected nodes.
return_event_data (bool, default: False) – Whether to track each individual transition event that occurs.
- Returns
t, S, I
- Return type
tuple of np.arrays
- Raises
HyperContagionError – If the user specifies both rho and initial_infecteds.