<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by G Ringwald on Medium]]></title>
        <description><![CDATA[Stories by G Ringwald on Medium]]></description>
        <link>https://medium.com/@guillaumeringwald?source=rss-6806c3e432a1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*W0IgcIkcI-2Ps_dem6Hg4w.jpeg</url>
            <title>Stories by G Ringwald on Medium</title>
            <link>https://medium.com/@guillaumeringwald?source=rss-6806c3e432a1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 18:02:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@guillaumeringwald/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Modeling the coronavirus epidemic and understand SIR models.]]></title>
            <link>https://medium.com/analytics-vidhya/a-simple-epidemiological-model-applied-to-the-coronavirus-covid-19-244a8e3ca608?source=rss-6806c3e432a1------2</link>
            <guid isPermaLink="false">https://medium.com/p/244a8e3ca608</guid>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[modelisation]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[coronavirus]]></category>
            <dc:creator><![CDATA[G Ringwald]]></dc:creator>
            <pubDate>Wed, 18 Mar 2020 02:16:11 GMT</pubDate>
            <atom:updated>2020-03-22T16:01:04.874Z</atom:updated>
            <content:encoded><![CDATA[<h3>Modeling the coronavirus epidemic and understand SIR models</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y1Y93SOF3VmV4pApnxc8bw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@fusion_medical_animation?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Fusion Medical Animation</a> on <a href="https://unsplash.com/s/photos/coronavirus?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>A simple epidemiological model applied to the coronavirus COVID-19</h3><p>#Coronavirus, #Covid-19, #Data science, #data visualisation, #epidemiology,</p><p>With the recent spread of the new coronavirus around the world it seems interesting to try to understand how the virus spread and to do some simulations to try to imagine how the situation can evolve.</p><p>I am a programer and machine learning engineer with passion to data science. As we are dealing with an exponential growth, modifying even slightly some parameters end up with results radically different. i am not epidemiologist so the goal of the notebook is more to illustrate the mechanisms of a spread of a virus, to give a high level understanding of exponential and logistic growth, and not to give accurate predictions even if they the next scenarios are my best guesses.</p><h4>Model Intuitions</h4><p>The model that we will use is inspired by the SIR model without vital Dynamics in T<a href="https://link.springer.com/chapter/10.1007/978-3-642-61317-3_5">hree Basic Epidemiological by HW Hethcote</a>. Without vital dynamics means that we don’t take into account natural death and babies borns as the timescale of the spread allow us to ignore those aspects. SIR stands for Suceptibles, Infective, Removed, we consider that people gains immunity, as it is usually the case for viruses.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rmkkLkNIJ9t3lOyCPHZaGw.png" /><figcaption>SIR model illustration</figcaption></figure><p>In this model, the population is divided into 3 main categories</p><ul><li><em>uninfected or healthy; </em>representing the population untouched by the virus,</li><li><em>infectious:</em> the people currently infected</li><li>and <em>previously infected</em> ( cured or dead)</li></ul><p>During the epidemic, some individuals pass from one category to another, there are 2 main streams:</p><ul><li>Decay: sick people are healed or die. The people that where infected but got better after <strong>X</strong> days are transferred from infectious to cured.</li><li><strong>Δ (</strong>Delta): infectious people transmit the virus to healthy individuals, this means that we transfer those people from the healthy bucket to the infectious bucket</li></ul><p>Once people are cured, we consider they have gained immunity and cannot be infected again. Here is a set of equation describing the transitions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DMCa62DCMwFHhfm_kZoc2g.png" /><figcaption>Algorithm we apply</figcaption></figure><p><strong>where r</strong> is the growth rate.</p><p>In reality, we use a slightly modified version to calculate <strong>Δ (</strong>n). It will allow us to take into account waves of spreadings or changes in confinement policies, and also to be more realistic:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tn66FLd7EOhdYxiEYjiPSQ.png" /></figure><p><strong>Min</strong></p><p>The minimum is here to not go over the total of the population which would not make sense.</p><p><strong>Logistic factor</strong></p><p>we added a logistic factor, it is simply to take into account the fact that the population is not infinite, the virus can spread only among remaining healthy people, also, if 80% of the population has already been contaminated, only 1 person over 5 can be infected.</p><p>that’s why logistic factor = remaining healthy /total population.</p><p><strong>Oscillations</strong></p><p>In order to take into account variations in growth, we pass as a parameter an array that contain coefficient that we will use periodically to change the growth rate ( more details below).</p><h3>Improved decay estimations</h3><p>Instead of simply removing the cases from 15 days before, we can use a normal distribution to remove some cases on the days surrounding the average. This allow to simulate that some people heal in less than 15 days and some require more time. We use the distribution that we can see on the plot below to improve our estimation of cured patients</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q9aIQBwj1_8Ply5Ex6jIfQ.png" /></figure><p>Estimates number of new cases before the 1st day of the simulation</p><p>When we run a simulation, it start today, with the number of cases observed today in the country. But we need data from the last 20 days regarding the new cases to estimates correctly the decay. unfortunately this data is not always available and it is quite fastidious to enter, instead we can estimates the number of new cases per day because at the beginning of the epidemic the we observe an exponential growth.</p><p>Indeed, u(n) = r**(nb_days since start of the epidemic),</p><p>so u(n-5) = r**(nb_days since start of the epidemic — 5)</p><p>We can find the nb_days since start of the epidemic with ln(u(n))/ ln(r)</p><p>You can find those 2 utilities functions here:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/93f41b7c22adac1ae4b83ce9df0a9162/href">https://medium.com/media/93f41b7c22adac1ae4b83ce9df0a9162/href</a></iframe><p>Another important element to modelize this epidemic is to sone have information about the virus:</p><h4>Estimates of the different constants for COVID-19</h4><ul><li><strong>number of days the symptoms lasts</strong>: <a href="https://www.worldometers.info/coronavirus/coronavirus-symptoms/#duration">15 days</a> for most of the cases</li><li><strong>mortality_rate</strong>: here it is equal to 1%. You can compute it with <em>nb of death / nb of case</em>, although some country test more than other, that’s why i established the mortality based on the country testing the most (south korea and germany) <a href="https://www.worldometers.info/coronavirus/country/south-korea/"><em>worldometers</em></a></li><li><strong>severity_rate</strong> = 2% based on worldometers too</li><li><strong>Growth rate: </strong>According to <a href="https://ourworldindata.org/coronavirus">Max Roser, Hannah Ritchie and Esteban Ortiz-Ospina (2020) — “Coronavirus Disease (COVID-19) — Statistics and Research”</a>, It makes more sense to look at the growth rate per country. We express the growth rate in term of doubling time. The doubling time is the time required so that the infectious population is multiplied by 2:</li></ul><p>According to the paper in :</p><p>China it doubled in 35 days<br>Italy it doubled in 5 days<br>Iran it doubled in 6 days<br>South Korea it doubled in 15 days<br>Spain doubled in 3 days<br>France doubled in 4 days<br>Germany doubled in 3 days<br>United States in 5 days<br>United Kingdom in 3 days</p><p>We can express the doubling time (Td) in term of a constant growth rate of <em>r% </em>with the following formula, <a href="https://en.wikipedia.org/wiki/Doubling_time">source</a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/1*3R8UEdZmMtx63O8sF0HZrQ.png" /></figure><h4>The model code</h4><p>this function calculate the evolution of proportions of uninfected, infectious, cured, dead people among a population as the virus spread, the parameters are:</p><ul><li>the size of the population</li><li>doubling time ( number of days for the number of infectious people to double)</li><li>number of infectious people today ( active cases)</li><li>current number of cured people</li><li>current number of dead people</li><li>number of new cases today</li><li>mortality rate (default from <a href="https://www.worldometers.info/coronavirus/country/south-korea/">worldometers</a> nb of death / nb of cases ),</li><li>hospitalisation rate (default at 0.01 <a href="https://www.worldometers.info/coronavirus/country/south-korea/">worldometers</a>)</li><li>infection time. average number of days to heal or die</li><li>number of days to run the simulation</li><li>annealing is to simulate progressive lockdown and back to more freedom of move</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bb70d3feb9e50f738f5e176310c7ba61/href">https://medium.com/media/bb70d3feb9e50f738f5e176310c7ba61/href</a></iframe><p>the plot function</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2d340342b813224a820ff67ca7357104/href">https://medium.com/media/2d340342b813224a820ff67ca7357104/href</a></iframe><h4>France with growth rate observed before the lockdown</h4><p>with a population of 67 million people, a doubling rate every 4 days, and an approximate number of infectious cases of 18000 (calculated with the number of death in the country and the mortality of South Korea) as most cases are not detected in this country we cannot us official digits.</p><pre>plot(66900000, 4, 12000, number_of_days_to_simulate<strong>=</strong>150)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*RvZNH-hGNvAxxuoHSkadfw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*lBL2s7kxjFnwJVBPZjPpTA.png" /></figure><p><strong>Analysis and comments</strong></p><ul><li>The number of infected people reaches 80% of the pop in early june. We can observe the phenomenon of herd immunity where a part of the population doesn’t get infected because too much people are already immune ( as they were previously infected ) and the virus stop to propagate. The % of population required to achieve it depends of the growth rate of the virus.</li><li>the pick of new cases is the 14/05</li><li>the number of sever cases goes up to 600k late may wich would saturate hospitals</li><li>number of victims go up to 600k</li><li>we can observe the transition of the population is very fast and with a number of infectious people being a significant portion of the pop</li></ul><h4>France after lockdown</h4><p>Lets imagine that the lockdown is just a little bit less efficient than in China and that the doubling time is around 20</p><p>plot(66900000, 20, 12000, number_of_days_to_simulate=365)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*CDdoX3jOjrd1clEkTWO7cA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*BnpYyNzE3yJ4RZS5EbFdgg.png" /></figure><p><strong>Analysis and comments</strong></p><p>We can see that the epidemic is now much less dangerous as the number of cases stay really low</p><p>I think the difference between the 2 scenarios explains the policies currently applied in Europe… I change dramatically the outcome and transform a super dangerous epidemic in a far more manageable one.</p><p>Now, let’s try to go beyond the lockdown vs not lockdown. For the next scenario, we won’t keep the growth rate constant. instead we will apply to it variations.</p><h4>Seasonality</h4><p>The spanish flu had 3 waves, the coronavirus could also be sensitive to seasons and you probably heard that it had good chance to stop in summer. we will use the following function to modulate the probability of the virus to infect new people. This function is cloth to 0 during summer months, and cloth to 1 during winter months. We use this function to multiply the growth rate <strong>r</strong> . After a the period of 365 days we restart a new cycle and reuse initial values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vdHRL-0KPaoIeGFkhHIv2g.png" /></figure><p>plot(66900000, 5, 12000, number_of_days_to_simulate=400, with_season=(1 + np.cos(np.linspace(portion_of_year, 2*np.pi +portion_of_year, 365))/2 ))</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*VAzS6u4xaH2OSeZLz3GBzw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*hFDWPf0JmaYZBMJZd55WdQ.png" /></figure><p>we can observe 2 picks, the second occurs in autumn and is the most powerful. Of course we might be then much more prepared, maybe huge progress would have been done in terms of testing and cure.</p><h4>Simulate periodic changes in lockdown severity</h4><p>we will use the following function to describe the lockdown removal. After 3 months, the number of cases decreases, the economy does’t look good and the government remove social distancing measures progressively, unfortunately here, the number of cases didn’t really droped to 0 and so the disease spread again, so quarantine are reintroduced again and so on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_YRMG_ZKvAInLTGgDMfc3g.png" /></figure><p>The following senario try to simulate the effect of lockdown oscillating between total lockdown and a to semi opened situation. From no growth at all to a doubling time of 10 days, which is higher than South Korea but below all European country and Iran were freedom of move is actually limited.<br>What is tricky is that changing this max growth rate change quite a bit the outcome, if you download the notebook, you will be able to see the difference in outcome between a doubling time of 10 vs doubling time of 9, it’s huge...</p><p>plot(66900000, 10, 12000, number_of_days_to_simulate=400, with_annealing=(1 + np.cos(np.linspace(-np.pi, np.pi, 90))/2 ))</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*0Na2WVzT05BJf8JAG_rm2A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*jtdor4zDpEoihLQvzaT5Og.png" /></figure><p>The situation is far better than if no limitation in population movement is introduced, but we still end up with several picks and several days where hospitals could be saturate. with a pick with 8k people having severe symptoms, the number of cases diminish after lock downs. 38k death in 1 year. It illustrates the need to maintain the social distancing as long as the virus can spread at the actual rate.</p><h4>Seasonal with lock down oscillations</h4><p>Here we try to apply both seasonal variations and changes in policy applied. We accelerate the speed of adaptation of political decisions, so that we have at least 1 pick during next winter. As we have 2 waves, they can be synchronous or asynchronus. We want to have at least a period were we use the full growth rate of 7% ( doubling time of 10 days)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l-UA41Nyqx0-wyp5B0B7Gg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*MPuD2KDcrVIVsWGuX5ANkQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*TwW3K6mbYaimICw7j5TUYw.png" /></figure><p>In this scenario, we can see that the worst would be next winter.</p><h3>An optimistic and the most probable scenario or what to expect from research progress</h3><h3>Improvements of tests:</h3><p>faster, and cheaper test would allow us to maintain a doubling rate very low without to have to block all the country. And achieve to slow the progression for minial economical costs</p><h3>Existing medicine that could be applied to this virus</h3><p>It could be ready quite fast, and it would decrease the mortality_rate and the severity rate, we would avoid saturation of hospitals and costs in lives</p><h3>A new vaccine</h3><p>In 12 to 24 months, so it is irrelevant for our model</p><pre>plot(66900000, 15, 12000, <br>     mortality_rate=0.001,<br>     hospitalization_rate=0.005,<br>     number_of_days_to_simulate=400, <br>     with_annealing=(1 + np.cos(np.linspace(-np.pi, np.pi, 45))/2 ), <br>     with_season=(1 + np.cos(np.linspace(portion_of_year, 2*np.pi +portion_of_year, 365))/2 )<br>)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*r-hLpWVQKxPUM3XpBlNjEA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*O3S6s_FJ2L90PZiBFRgcIw.png" /></figure><p>Here we can see that the number of people that would need special care and the number of victim is marginal</p><p>I hope you gained some intuitions about the mechanism of an epidemic, how spectacularly fast can be a logistic growth. I hope also you learned 1 or 2 thing and enjoyed this reading, don’t hesitate to give some claps ;)</p><h4>To continue</h4><p>You can access the notebook on <a href="https://colab.research.google.com/drive/1Ncs76AuhUDH5LbTikQXMZTkBDQE6EDSj#scrollTo=PcMdxgkJt0Vy">google colab</a>, where you can access the interactive versions of the charts, change the different parameters or apply the different simulations to your country.</p><p>The source code is on <a href="https://github.com/gringParis/coronavirus-simulation/blob/master/Coronavirus%20Covi19%20simulation.ipynb">github</a>, feel free to fork it if you want to extend it.</p><p>Please don’t hesitate to give me your own opinion, or if you want me to complete the notebook for example with other countries or other scenarios.</p><p>And if you read till this sentence, congratulations and thank you :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=244a8e3ca608" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/a-simple-epidemiological-model-applied-to-the-coronavirus-covid-19-244a8e3ca608">Modeling the coronavirus epidemic and understand SIR models.</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>