r/Python • • Mar 11 '20

I Made This Really simple simulation of virus spreading. Black dots are people, yellow dots are infected (it starts from 1). Each cell visited by an infected can infect other people passing through that for 3 iterations. After 20 iterations a person is infected is deleted from the grid.

1.4k Upvotes

128 comments sorted by

View all comments

1

u/[deleted] Mar 12 '20

How did you model this mathematically? Can you tell us more about the function

1

u/[deleted] Mar 12 '20

everything regarding the model is written in the title... I just forgot to say that a person who passes through an infected cell gets infected with a probability of 0.6... the people are moving using a simple random walk (up/down/left/right for each iteration). recap:

  1. 2D grid 100x100 representing the space

  2. Each cell of the grid can be contaminated or not contaminated. After three timesteps a cell is contaminated comes back to be not contaminated

  3. It starts from a population of 1000 people with one infected.

  4. People are moving through random walks

  5. If an infected person passes through a not contaminated cell the cell becomes contaminated, if it's already contaminated the timer of the contamination start over

  6. If a person not infected passes through a contaminated cell has a probability of 0.6 to get infected

  7. After 20 timesteps a person is infected is deleted from the list of people (and from the grid)

If you want to know something more specific just ask... but I think that's it... pretty easy model...