API

zero_d

covid_19_simulations.zero_d.infect(df, trans_rate, day_name)[source]

Simulates a single day of infection. Each infected person

NOTE: a 0 counts as infected, while a 1 is healthy.

Inputs:
df : (pandas DataFrame) object holding all values of infected people. Each
column of “infected day _” corresponds to a different day, with “_” being some integer or float. The “name” column assigns a name to each object, independent of index. In the infected columns, a 0 counts as infected, while a 1 is healthy.
trans_rate : (float) rate of transmission between individuals. infection
is performed in a probabilistic manner, casting it as a draw from a binomial distribution with a rate of 1 - trans_rate.
day_name : (float or int) the day of this infection, used to create a new
column in the dataframe tracking the day’s infections.
Outputs:
df : (pandas DataFrame) object, same as the input, but with a new column
holding this day’s infected results.
covid_19_simulations.zero_d.simulate(N, trans_rate, t_steps, N_initial)[source]

Simulates an infection run.

Inputs:

N : (int) number of individuals in the system. trans_rate : (float) rate of transmission between individuals. infection

is performed in a probabilistic manner, casting it as a draw from a binomial distribution with a rate of 1 - trans_rate.

t_steps : (int) number of time steps (“days”) to consider. N_initial : (int) number of initially infected individuals.

Outputs:
df : (pandas DataFrame) object holding all values of infected people. Each
column of “infected day _” corresponds to a different day, with “_” being some integer or float. The “name” column assigns a name to each object, independent of index. In the infected columns, a 0 counts as infected, while a 1 is healthy.

one_d

covid_19_simulations.one_d.animate_histogram(df, title)[source]

animates a histogram.

adapted from https://matplotlib.org/gallery/animation/animated_histogram.html

covid_19_simulations.one_d.infect1D(df, trans_rate, day_name, thresh, power)[source]

Simulates a single day of infection in 1D.

NOTE: a 0 counts as infected, while a 1 is healthy.

Inputs:
df : (pandas DataFrame) object holding all values of infected people. Each
column of “infected day _” corresponds to a different day, with “_” being some integer or float. The “name” column assigns a name to each object, independent of index. In the infected columns, a 0 counts as infected, while a 1 is healthy.
trans_rate : (float) rate of transmission between individuals. infection
is performed in a probabilistic manner, casting it as a draw from a binomial distribution with a rate of 1 - trans_rate.
day_name : (float or int) the day of this infection, used to create a new
column in the dataframe tracking the day’s infections.
Outputs:
df : (pandas DataFrame) object, same as the input, but with a new column
holding this day’s infected results.
covid_19_simulations.one_d.simulate1D(N, trans_rate, t_steps, N_initial, thresh, power, distrib_pop, distrib_infec, kwargs_for_pop={}, kwargs_for_infec={})[source]

Simulates an infection run in 1D.

Inputs:

N : (int) number of individuals in the system. trans_rate : (float) rate of transmission between individuals. infection

is performed in a probabilistic manner, casting it as a draw from a binomial distribution with a rate of 1 - trans_rate.

t_steps : (int) number of time steps (“days”) to consider. N_initial : (int) number of initially infected individuals. thresh : (float) distance less than which infection is transmitted at the trans_rate;

that is, less than which this function returns a value of 1. At a distance greater than this, this function returns 1/distance^power.
power : (float) Greater than 0. Power to which the multiplier falls off if the distance
is greater than some threshold.

distrib_pop : (func) distribution function to determine how individuals are initialized. distrib_infec : (func) distribution function to determine how initial infections are initialized. kwargs_for_pop : (dict) keyword arguments passed to the distrib_pop distribution type.

Size not included.
kwargs_for_infec : (dict) keyword arguments passed to the distrib_infect distribution type. Size not
included.
Outputs:
df : (pandas DataFrame) object holding all values of infected people. Each
column of “infected day _” corresponds to a different day, with “_” being some integer or float. The “name” column assigns a name to each object, independent of index. In the infected columns, a 0 counts as infected, while a 1 is healthy.

two_d

covid_19_simulations.two_d.distance(frame, ind1, ind2)[source]

Just finding the distance between two rows and their x-y pairs.

covid_19_simulations.two_d.do_multiplier(x, y, power, thresh, df_sorted, df2D_test, farthest_calc)[source]
covid_19_simulations.two_d.find_first[source]

return the index of the first occurence of item in vec

covid_19_simulations.two_d.infect2D(df, trans_rate, day_name, thresh, power, df_sorted, farthest_calc)[source]

Simulates a single day of infection in 1D.

NOTE: a 0 counts as infected, while a 1 is healthy.

Inputs:
df : (pandas DataFrame) object holding all values of infected people. Each
column of “infected day _” corresponds to a different day, with “_” being some integer or float. The “name” column assigns a name to each object, independent of index. In the infected columns, a 0 counts as infected, while a 1 is healthy.
trans_rate : (float) rate of transmission between individuals. infection
is performed in a probabilistic manner, casting it as a draw from a binomial distribution with a rate of 1 - trans_rate.
day_name : (float or int) the day of this infection, used to create a new
column in the dataframe tracking the day’s infections.

dist_matrix : (numpy.ndarray) distance matrix holding the distances between all individuals.

Outputs:
df : (pandas DataFrame) object, same as the input, but with a new column
holding this day’s infected results.
covid_19_simulations.two_d.initialize_pop_2D(N, distrib, **kwargs)[source]

This will change once we have the U.S. map.

distrib: size is not a thing again.

covid_19_simulations.two_d.simulate2D(N, trans_rate, t_steps, N_initial, thresh, power, distrib_pop, distrib_infec, kwargs_for_pop={}, kwargs_for_infec={})[source]

Simulates an infection run in 1D.

Inputs:

N : (int) number of individuals in the system. trans_rate : (float) rate of transmission between individuals. infection

is performed in a probabilistic manner, casting it as a draw from a binomial distribution with a rate of 1 - trans_rate.

t_steps : (int) number of time steps (“days”) to consider. N_initial : (int) number of initially infected individuals. thresh : (float) distance less than which infection is transmitted at the trans_rate;

that is, less than which this function returns a value of 1. At a distance greater than this, this function returns 1/distance^power.
power : (float) Greater than 0. Power to which the multiplier falls off if the distance
is greater than some threshold.

distrib_pop : (func) distribution function to determine how individuals are initialized. distrib_infec : (func) distribution function to determine how initial infections are initialized. kwargs_for_pop : (dict) keyword arguments passed to the distrib_pop distribution type.

Size not included.
kwargs_for_infec : (dict) keyword arguments passed to the distrib_infect distribution type. Size not
included.
Outputs:
df : (pandas DataFrame) object holding all values of infected people. Each
column of “infected day _” corresponds to a different day, with “_” being some integer or float. The “name” column assigns a name to each object, independent of index. In the infected columns, a 0 counts as infected, while a 1 is healthy.