SlideShare a Scribd company logo
1 of 2
Download to read offline
Simulation rules are almost the same to what I coded using Python but with one interesting
addition a partial immunity (see details below). The main difference between the Python version
and R-version of the code would be the use of vectorization. You should use as little as possible
of loops. In fact, there should be just one loop for the days-count. If anyone tries to create the
exact copy of my Python code but in R, the grade will be quite low. Below are rules that should
help you building a simulation model:
1. We assume that there are N_population citizens in a population. N_population is an input
parameter. During development and testing you can have it small, but your code should be able
to handle a reasonably large value for population size.
2. Every citizen has a health state healthy, sick, dead (or you can code it as 0, 1, 2). When we
start, all citizens are alive and healthy
3. To start the pandemic, you randomly mark a small number of citizens as sick there can be a
parameter for the number of initially infected citizens. You can start with 1 or 2 initial sick cases.
4. One iteration is one day. During the day, every citizen can meet a random number (say
between 0 and 20 inclusive) of randomly selected citizens. You dont really need to control all
citizens as we are interested in meetings of sick people only. We dont care how many healthy
people meet each other.
5. Every sick citizen can stay sick and infectious for 10 days, hence you should have some
counter for each sick citizen. After 10 days a sick citizen becomes healthy and stops spreading
the virus
6. Obviously, dead citizens cannot become sick, they dont meet anyone and, as a result, cannot
infect anyone.
7. During the day every sick citizen has a probability to die (mortality rate) from the disease with
probability 0.5% (quite low probability).
8. If a sick citizen does not die, then they can meet other people as per the rule 4 above, and if
they meet a healthy person, that person might become sick too and start infecting other people
starting from the next day (that is an infection day is day 0 of their sickness). The probability for
a citizen of becoming sick (infection rate) after a contact is 30% (this is quite high).
9. (New rule!) After surviving the infection and getting healthy, the person becomes immune.
This is a partial immunity. It does not make the person invincible but reduces the chance of
infection in future meetings with sick people. Take the immunity coefficient as 0.1. That is, a
probability of being infected for immune person is ten times lower than for the person without an
immunity. The infection rate for the immune person is the original infection rate multiplied by
the immunity coefficient, e.g. (0.3*0.1).
For the test, you can set immunity coefficient equal 1, which means no benefits of immunity and
the result should be the same as in Python example I presented.
10. You should run this simulation for a number of days (iterations) and store each day results in
a data frame: how many sick citizens in population in total, how many people died, how many
new infections per day, something else you might find interesting or useful (e.g. R0). After
completing the simulation, you should create a data visualisation of the history of infection.
11. You can run simulations for a predefined number of days, say 100 or 300 days, or till some
natural outcome all citizens get healthy, or all citizens die
12. Keep all parameters in the beginning of the code, so you can easily change them without a
need to change anything in the code.
13. Try to change parameters of the model increase mortality rate (more dangerous virus
scenario SARS and MERC had 3% mortality); or decrease infection rate (say, 5% wearing
masks and social distance scenario); or increase the length of sickness period; or reduce the
number of possible contacts for all citizens to a range between 0 and 2 (lockdown scenario).
Make a brief comment (3-4 lines as comments at the end of the Rscript) on what parameters have
the strongest effect on the infection growth.
The main purpose of this exercise is to test your understanding of programming in R: using
vectorization, indexing, plotting
Hint on getting a random event for a given probability:
If you know that some event has probability 75% (e.g., coin tossing on head this is clearly a
biased coin), then you generate a random number from a uniform distribution between 0 and 1,
e.g., x <- runif(n = 1)
And then, if x < 0.75 is TRUE we assume coin to be on head; if FALSE we assume the coin is
on tail.
Thanks to vectorization we can create a very large number of random numbers by changing
parameter n and then test all these numbers if they are less than 0.75. Beware of a relationship
between percentage and proportion in probability: 75% means 0.75; 0.5% means 0.005.

More Related Content

Similar to Simulation rules are almost the same to what I coded using Python bu.pdf

MathematicallyModelingEpidemicsThroughtheUseoftheReed-FrostEquation
MathematicallyModelingEpidemicsThroughtheUseoftheReed-FrostEquationMathematicallyModelingEpidemicsThroughtheUseoftheReed-FrostEquation
MathematicallyModelingEpidemicsThroughtheUseoftheReed-FrostEquationAlexander Kaunzinger
 
Modeling and qualitative analysis of malaria epidemiology
Modeling and qualitative analysis of malaria epidemiologyModeling and qualitative analysis of malaria epidemiology
Modeling and qualitative analysis of malaria epidemiologyIOSR Journals
 
Mathematical Model of Varicella Zoster Virus - Abbie Jakubovic
Mathematical Model of Varicella Zoster Virus - Abbie JakubovicMathematical Model of Varicella Zoster Virus - Abbie Jakubovic
Mathematical Model of Varicella Zoster Virus - Abbie JakubovicAbbie Jakubovic
 
I appreciate any answer. Thank you. For each of the following descri.pdf
I appreciate any answer. Thank you. For each of the following descri.pdfI appreciate any answer. Thank you. For each of the following descri.pdf
I appreciate any answer. Thank you. For each of the following descri.pdfamiteksecurity
 
This project will investigate the SIR model and use numeric methods t.pdf
 This project will investigate the SIR model and use numeric methods t.pdf This project will investigate the SIR model and use numeric methods t.pdf
This project will investigate the SIR model and use numeric methods t.pdfjkcs20004
 
CHITNIS_017-05-08-MMCVECID-Intro SEIR.pdf
CHITNIS_017-05-08-MMCVECID-Intro SEIR.pdfCHITNIS_017-05-08-MMCVECID-Intro SEIR.pdf
CHITNIS_017-05-08-MMCVECID-Intro SEIR.pdfAdhyaDubey1
 
Infectious disease modelling - the math behind Corona
Infectious disease modelling - the math behind CoronaInfectious disease modelling - the math behind Corona
Infectious disease modelling - the math behind CoronaWouter de Heij
 
HMisiri_Estimating HIV incidence from grouped cross-sectional data in setting...
HMisiri_Estimating HIV incidence from grouped cross-sectional data in setting...HMisiri_Estimating HIV incidence from grouped cross-sectional data in setting...
HMisiri_Estimating HIV incidence from grouped cross-sectional data in setting...College of Medicine(University of Malawi)
 
A SEIR MODEL FOR CONTROL OF INFECTIOUS DISEASES
A SEIR MODEL FOR CONTROL OF INFECTIOUS DISEASESA SEIR MODEL FOR CONTROL OF INFECTIOUS DISEASES
A SEIR MODEL FOR CONTROL OF INFECTIOUS DISEASESSOUMYADAS835019
 
The Susceptible-Infectious Model of Disease Expansion Analyzed Under the Scop...
The Susceptible-Infectious Model of Disease Expansion Analyzed Under the Scop...The Susceptible-Infectious Model of Disease Expansion Analyzed Under the Scop...
The Susceptible-Infectious Model of Disease Expansion Analyzed Under the Scop...cscpconf
 
THE SUSCEPTIBLE-INFECTIOUS MODEL OF DISEASE EXPANSION ANALYZED UNDER THE SCOP...
THE SUSCEPTIBLE-INFECTIOUS MODEL OF DISEASE EXPANSION ANALYZED UNDER THE SCOP...THE SUSCEPTIBLE-INFECTIOUS MODEL OF DISEASE EXPANSION ANALYZED UNDER THE SCOP...
THE SUSCEPTIBLE-INFECTIOUS MODEL OF DISEASE EXPANSION ANALYZED UNDER THE SCOP...csandit
 
Modeling the Effect of Variation of Recruitment Rate on the Transmission Dyna...
Modeling the Effect of Variation of Recruitment Rate on the Transmission Dyna...Modeling the Effect of Variation of Recruitment Rate on the Transmission Dyna...
Modeling the Effect of Variation of Recruitment Rate on the Transmission Dyna...IOSR Journals
 
Sample, disease modeling vzv
Sample, disease modeling vzvSample, disease modeling vzv
Sample, disease modeling vzvKellieWatkins1
 
Epidemiological modelling
Epidemiological modellingEpidemiological modelling
Epidemiological modellingSumit Das
 
Avian Influenza (H5N1) Expert System using Dempster-Shafer Theory
Avian Influenza (H5N1) Expert System using Dempster-Shafer TheoryAvian Influenza (H5N1) Expert System using Dempster-Shafer Theory
Avian Influenza (H5N1) Expert System using Dempster-Shafer TheoryAndino Maseleno
 
Sensitivity Analysis of the Dynamical Spread of Ebola Virus Disease
Sensitivity Analysis of the Dynamical Spread of Ebola Virus DiseaseSensitivity Analysis of the Dynamical Spread of Ebola Virus Disease
Sensitivity Analysis of the Dynamical Spread of Ebola Virus DiseaseAI Publications
 

Similar to Simulation rules are almost the same to what I coded using Python bu.pdf (20)

MathematicallyModelingEpidemicsThroughtheUseoftheReed-FrostEquation
MathematicallyModelingEpidemicsThroughtheUseoftheReed-FrostEquationMathematicallyModelingEpidemicsThroughtheUseoftheReed-FrostEquation
MathematicallyModelingEpidemicsThroughtheUseoftheReed-FrostEquation
 
F0623642
F0623642F0623642
F0623642
 
Modeling and qualitative analysis of malaria epidemiology
Modeling and qualitative analysis of malaria epidemiologyModeling and qualitative analysis of malaria epidemiology
Modeling and qualitative analysis of malaria epidemiology
 
Mathematical Model of Varicella Zoster Virus - Abbie Jakubovic
Mathematical Model of Varicella Zoster Virus - Abbie JakubovicMathematical Model of Varicella Zoster Virus - Abbie Jakubovic
Mathematical Model of Varicella Zoster Virus - Abbie Jakubovic
 
I appreciate any answer. Thank you. For each of the following descri.pdf
I appreciate any answer. Thank you. For each of the following descri.pdfI appreciate any answer. Thank you. For each of the following descri.pdf
I appreciate any answer. Thank you. For each of the following descri.pdf
 
This project will investigate the SIR model and use numeric methods t.pdf
 This project will investigate the SIR model and use numeric methods t.pdf This project will investigate the SIR model and use numeric methods t.pdf
This project will investigate the SIR model and use numeric methods t.pdf
 
CHITNIS_017-05-08-MMCVECID-Intro SEIR.pdf
CHITNIS_017-05-08-MMCVECID-Intro SEIR.pdfCHITNIS_017-05-08-MMCVECID-Intro SEIR.pdf
CHITNIS_017-05-08-MMCVECID-Intro SEIR.pdf
 
Infectious disease modelling - the math behind Corona
Infectious disease modelling - the math behind CoronaInfectious disease modelling - the math behind Corona
Infectious disease modelling - the math behind Corona
 
HMisiri_Estimating HIV incidence from grouped cross-sectional data in setting...
HMisiri_Estimating HIV incidence from grouped cross-sectional data in setting...HMisiri_Estimating HIV incidence from grouped cross-sectional data in setting...
HMisiri_Estimating HIV incidence from grouped cross-sectional data in setting...
 
A SEIR MODEL FOR CONTROL OF INFECTIOUS DISEASES
A SEIR MODEL FOR CONTROL OF INFECTIOUS DISEASESA SEIR MODEL FOR CONTROL OF INFECTIOUS DISEASES
A SEIR MODEL FOR CONTROL OF INFECTIOUS DISEASES
 
The Susceptible-Infectious Model of Disease Expansion Analyzed Under the Scop...
The Susceptible-Infectious Model of Disease Expansion Analyzed Under the Scop...The Susceptible-Infectious Model of Disease Expansion Analyzed Under the Scop...
The Susceptible-Infectious Model of Disease Expansion Analyzed Under the Scop...
 
THE SUSCEPTIBLE-INFECTIOUS MODEL OF DISEASE EXPANSION ANALYZED UNDER THE SCOP...
THE SUSCEPTIBLE-INFECTIOUS MODEL OF DISEASE EXPANSION ANALYZED UNDER THE SCOP...THE SUSCEPTIBLE-INFECTIOUS MODEL OF DISEASE EXPANSION ANALYZED UNDER THE SCOP...
THE SUSCEPTIBLE-INFECTIOUS MODEL OF DISEASE EXPANSION ANALYZED UNDER THE SCOP...
 
Modeling the Effect of Variation of Recruitment Rate on the Transmission Dyna...
Modeling the Effect of Variation of Recruitment Rate on the Transmission Dyna...Modeling the Effect of Variation of Recruitment Rate on the Transmission Dyna...
Modeling the Effect of Variation of Recruitment Rate on the Transmission Dyna...
 
Schwab_Thesis
Schwab_ThesisSchwab_Thesis
Schwab_Thesis
 
Al04606233238
Al04606233238Al04606233238
Al04606233238
 
Sample, disease modeling vzv
Sample, disease modeling vzvSample, disease modeling vzv
Sample, disease modeling vzv
 
Epidemiological modelling
Epidemiological modellingEpidemiological modelling
Epidemiological modelling
 
Sir presentation
Sir presentationSir presentation
Sir presentation
 
Avian Influenza (H5N1) Expert System using Dempster-Shafer Theory
Avian Influenza (H5N1) Expert System using Dempster-Shafer TheoryAvian Influenza (H5N1) Expert System using Dempster-Shafer Theory
Avian Influenza (H5N1) Expert System using Dempster-Shafer Theory
 
Sensitivity Analysis of the Dynamical Spread of Ebola Virus Disease
Sensitivity Analysis of the Dynamical Spread of Ebola Virus DiseaseSensitivity Analysis of the Dynamical Spread of Ebola Virus Disease
Sensitivity Analysis of the Dynamical Spread of Ebola Virus Disease
 

More from snewfashion

Solve the coding errors for upvotemake test-statsg++ -g -std=c++.pdf
Solve the coding errors for upvotemake test-statsg++ -g -std=c++.pdfSolve the coding errors for upvotemake test-statsg++ -g -std=c++.pdf
Solve the coding errors for upvotemake test-statsg++ -g -std=c++.pdfsnewfashion
 
Sergio and Malena were married for 10 years before Malena unexpected.pdf
Sergio and Malena were married for 10 years before Malena unexpected.pdfSergio and Malena were married for 10 years before Malena unexpected.pdf
Sergio and Malena were married for 10 years before Malena unexpected.pdfsnewfashion
 
Seg�n Bauer (2004), los sistemas de incorporaci�n var�an desde un en.pdf
Seg�n Bauer (2004), los sistemas de incorporaci�n var�an desde un en.pdfSeg�n Bauer (2004), los sistemas de incorporaci�n var�an desde un en.pdf
Seg�n Bauer (2004), los sistemas de incorporaci�n var�an desde un en.pdfsnewfashion
 
Select Your Tool Choose the tool that suits your preference�whether.pdf
Select Your Tool Choose the tool that suits your preference�whether.pdfSelect Your Tool Choose the tool that suits your preference�whether.pdf
Select Your Tool Choose the tool that suits your preference�whether.pdfsnewfashion
 
Sarasota Company has decided to expand its operations. The bo Prepar.pdf
Sarasota Company has decided to expand its operations. The bo Prepar.pdfSarasota Company has decided to expand its operations. The bo Prepar.pdf
Sarasota Company has decided to expand its operations. The bo Prepar.pdfsnewfashion
 
reword this paragraph The �digital divide� is a term used to descr.pdf
reword this paragraph  The �digital divide� is a term used to descr.pdfreword this paragraph  The �digital divide� is a term used to descr.pdf
reword this paragraph The �digital divide� is a term used to descr.pdfsnewfashion
 
Scenario 3 Urgent Care CenterImplement and plan steps necessary f.pdf
Scenario 3 Urgent Care CenterImplement and plan steps necessary f.pdfScenario 3 Urgent Care CenterImplement and plan steps necessary f.pdf
Scenario 3 Urgent Care CenterImplement and plan steps necessary f.pdfsnewfashion
 
Requirement 2. Prepare a statement of stockholders equity forCent.pdf
Requirement 2. Prepare a statement of stockholders equity forCent.pdfRequirement 2. Prepare a statement of stockholders equity forCent.pdf
Requirement 2. Prepare a statement of stockholders equity forCent.pdfsnewfashion
 
Task 5 Policy review 5 Why might the health and safety policy requi.pdf
Task 5 Policy review 5 Why might the health and safety policy requi.pdfTask 5 Policy review 5 Why might the health and safety policy requi.pdf
Task 5 Policy review 5 Why might the health and safety policy requi.pdfsnewfashion
 

More from snewfashion (9)

Solve the coding errors for upvotemake test-statsg++ -g -std=c++.pdf
Solve the coding errors for upvotemake test-statsg++ -g -std=c++.pdfSolve the coding errors for upvotemake test-statsg++ -g -std=c++.pdf
Solve the coding errors for upvotemake test-statsg++ -g -std=c++.pdf
 
Sergio and Malena were married for 10 years before Malena unexpected.pdf
Sergio and Malena were married for 10 years before Malena unexpected.pdfSergio and Malena were married for 10 years before Malena unexpected.pdf
Sergio and Malena were married for 10 years before Malena unexpected.pdf
 
Seg�n Bauer (2004), los sistemas de incorporaci�n var�an desde un en.pdf
Seg�n Bauer (2004), los sistemas de incorporaci�n var�an desde un en.pdfSeg�n Bauer (2004), los sistemas de incorporaci�n var�an desde un en.pdf
Seg�n Bauer (2004), los sistemas de incorporaci�n var�an desde un en.pdf
 
Select Your Tool Choose the tool that suits your preference�whether.pdf
Select Your Tool Choose the tool that suits your preference�whether.pdfSelect Your Tool Choose the tool that suits your preference�whether.pdf
Select Your Tool Choose the tool that suits your preference�whether.pdf
 
Sarasota Company has decided to expand its operations. The bo Prepar.pdf
Sarasota Company has decided to expand its operations. The bo Prepar.pdfSarasota Company has decided to expand its operations. The bo Prepar.pdf
Sarasota Company has decided to expand its operations. The bo Prepar.pdf
 
reword this paragraph The �digital divide� is a term used to descr.pdf
reword this paragraph  The �digital divide� is a term used to descr.pdfreword this paragraph  The �digital divide� is a term used to descr.pdf
reword this paragraph The �digital divide� is a term used to descr.pdf
 
Scenario 3 Urgent Care CenterImplement and plan steps necessary f.pdf
Scenario 3 Urgent Care CenterImplement and plan steps necessary f.pdfScenario 3 Urgent Care CenterImplement and plan steps necessary f.pdf
Scenario 3 Urgent Care CenterImplement and plan steps necessary f.pdf
 
Requirement 2. Prepare a statement of stockholders equity forCent.pdf
Requirement 2. Prepare a statement of stockholders equity forCent.pdfRequirement 2. Prepare a statement of stockholders equity forCent.pdf
Requirement 2. Prepare a statement of stockholders equity forCent.pdf
 
Task 5 Policy review 5 Why might the health and safety policy requi.pdf
Task 5 Policy review 5 Why might the health and safety policy requi.pdfTask 5 Policy review 5 Why might the health and safety policy requi.pdf
Task 5 Policy review 5 Why might the health and safety policy requi.pdf
 

Recently uploaded

_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 

Recently uploaded (20)

_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 

Simulation rules are almost the same to what I coded using Python bu.pdf

  • 1. Simulation rules are almost the same to what I coded using Python but with one interesting addition a partial immunity (see details below). The main difference between the Python version and R-version of the code would be the use of vectorization. You should use as little as possible of loops. In fact, there should be just one loop for the days-count. If anyone tries to create the exact copy of my Python code but in R, the grade will be quite low. Below are rules that should help you building a simulation model: 1. We assume that there are N_population citizens in a population. N_population is an input parameter. During development and testing you can have it small, but your code should be able to handle a reasonably large value for population size. 2. Every citizen has a health state healthy, sick, dead (or you can code it as 0, 1, 2). When we start, all citizens are alive and healthy 3. To start the pandemic, you randomly mark a small number of citizens as sick there can be a parameter for the number of initially infected citizens. You can start with 1 or 2 initial sick cases. 4. One iteration is one day. During the day, every citizen can meet a random number (say between 0 and 20 inclusive) of randomly selected citizens. You dont really need to control all citizens as we are interested in meetings of sick people only. We dont care how many healthy people meet each other. 5. Every sick citizen can stay sick and infectious for 10 days, hence you should have some counter for each sick citizen. After 10 days a sick citizen becomes healthy and stops spreading the virus 6. Obviously, dead citizens cannot become sick, they dont meet anyone and, as a result, cannot infect anyone. 7. During the day every sick citizen has a probability to die (mortality rate) from the disease with probability 0.5% (quite low probability). 8. If a sick citizen does not die, then they can meet other people as per the rule 4 above, and if they meet a healthy person, that person might become sick too and start infecting other people starting from the next day (that is an infection day is day 0 of their sickness). The probability for a citizen of becoming sick (infection rate) after a contact is 30% (this is quite high). 9. (New rule!) After surviving the infection and getting healthy, the person becomes immune. This is a partial immunity. It does not make the person invincible but reduces the chance of infection in future meetings with sick people. Take the immunity coefficient as 0.1. That is, a probability of being infected for immune person is ten times lower than for the person without an immunity. The infection rate for the immune person is the original infection rate multiplied by the immunity coefficient, e.g. (0.3*0.1). For the test, you can set immunity coefficient equal 1, which means no benefits of immunity and
  • 2. the result should be the same as in Python example I presented. 10. You should run this simulation for a number of days (iterations) and store each day results in a data frame: how many sick citizens in population in total, how many people died, how many new infections per day, something else you might find interesting or useful (e.g. R0). After completing the simulation, you should create a data visualisation of the history of infection. 11. You can run simulations for a predefined number of days, say 100 or 300 days, or till some natural outcome all citizens get healthy, or all citizens die 12. Keep all parameters in the beginning of the code, so you can easily change them without a need to change anything in the code. 13. Try to change parameters of the model increase mortality rate (more dangerous virus scenario SARS and MERC had 3% mortality); or decrease infection rate (say, 5% wearing masks and social distance scenario); or increase the length of sickness period; or reduce the number of possible contacts for all citizens to a range between 0 and 2 (lockdown scenario). Make a brief comment (3-4 lines as comments at the end of the Rscript) on what parameters have the strongest effect on the infection growth. The main purpose of this exercise is to test your understanding of programming in R: using vectorization, indexing, plotting Hint on getting a random event for a given probability: If you know that some event has probability 75% (e.g., coin tossing on head this is clearly a biased coin), then you generate a random number from a uniform distribution between 0 and 1, e.g., x <- runif(n = 1) And then, if x < 0.75 is TRUE we assume coin to be on head; if FALSE we assume the coin is on tail. Thanks to vectorization we can create a very large number of random numbers by changing parameter n and then test all these numbers if they are less than 0.75. Beware of a relationship between percentage and proportion in probability: 75% means 0.75; 0.5% means 0.005.