<jupyter_start><jupyter_text>Assuming that individuals stay in the 'Exposed' state for exactly one day, the 6-day test frequency is sufficient for mitigating an outbreak, assuming the "bucket approach" where everyone is tested every 6 days<jupyter_code>plot_sims(dfs_cts_test, dfs_bucket_test, params)
params_E_3 = params.copy()
params_E_3['max_time_exposed'] = 8
params_E_3['exposed_time_function'] = lambda n: np.random.multinomial(n, holding_time_3)

sim_E_3_cts_test = StochasticSimulation(params_E_3)
dfs_E_3_cts_test = []
for _ in range(100):
    dfs_E_3_cts_test.append(sim_E_3_cts_test.run_new_trajectory(250))
params_bucket_E_3 = params_E_3.copy()
params_bucket_E_3['days_between_tests'] = 6
params_bucket_E_3['test_population_fraction'] = 1

sim_bucket_E_3 = StochasticSimulation(params_bucket_E_3)
dfs_bucket_E_3 = []
for _ in range(100):
    dfs_bucket_E_3.append(sim_bucket_E_3.run_new_trajectory(250))<jupyter_output><empty_output><jupyter_text>On the other hand, changing the distribution of time spent in the 'E' state from deterministically 1 day to stochastic Poisson(3) days (capped at 8 days), a major outbreak occurs under both testing protocols<jupyter_code>plot_sims(dfs_E_3_cts_test, dfs_bucket_E_3, params)<jupyter_output><empty_output><jupyter_text>A note on analyzing this data: trajectories are dataframes; each row gives counts of people in each state on each day<jupyter_code># all of the trajectories created above are lists of data frames.  
# Data frames are designed to be easy to analyze.

trajectory_df = dfs_bucket_E_3[0]
trajectory_df.head(n=10)<jupyter_output><empty_output><jupyter_text>notice that a huge buildup accumulates in the E queue before any major buildup occurs in the ID queue<jupyter_code>trajectory_df.head(n=30)<jupyter_output><empty_output><jupyter_text>Does using geometric holding time, instead of Poisson, change the outcome<jupyter_code>from scipy.stats import geom
def E_dist_geom(max_time, mean_time):
    pmf = list()
    for i in range(1, max_time):
        pmf.append(geom.pmf(i, 1/mean_time))
    pmf.append(1-np.sum(pmf))
    return np.array(pmf)

holding_time_3_geom = E_dist_geom(8, 3)
params_bucket_E_3_geom = params_bucket_E_3.copy()
params_bucket_E_3_geom['exposed_time_function'] = lambda n: np.random.multinomial(n, holding_time_3_geom)

sim_bucket_E_3_geom = StochasticSimulation(params_bucket_E_3_geom)
dfs_bucket_E_3_geom = []
for _ in range(100):
    dfs_bucket_E_3_geom.append(sim_bucket_E_3_geom.run_new_trajectory(250))
plot_sims(dfs_bucket_E_3_geom, dfs_bucket_E_3_geom, params)
dfs_bucket_E_3_geom[0]<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup