You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello. I have been able to figure out a solution for this. The main thing I was missing was how to access the time series data. This can be done through node_counts = trends[0]['trends']['node_count']. This structure provides lists of node counts per time step for each state, which is essential for calculating the average proportion of nodes in each state over time.
The following code helps in finding the areas under the curves:
**_node_counts = trends[0]['trends']['node_count']
areas = {}
for state_key, y_values in node_counts.items():
x_values = np.arange(len(y_values))
area = np.trapz(y_values, x=x_values) / N
areas[state_key] = area
for state_key, area in areas.items():
print(f"Normalized area under the curve for {state_key}: {area}")_**
Entire code for an example SIR epidemic simulation:
N = 1000
g = nx.erdos_renyi_graph(N, 0.1)
model = ep.SIRModel(g)
config = mc.Configuration()
config.add_model_parameter("beta", 0.01)
config.add_model_parameter("gamma", 0.005)
infected_nodes = list(range(10))
config.add_model_initial_configuration("Infected", infected_nodes)
model.set_initial_status(config)
How can I calculate the area under the curves? For example I want to compute the area under the infected curve, how can I do that?
The text was updated successfully, but these errors were encountered: