SlideShare a Scribd company logo
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

Session ii g3 overview epidemiology modeling mmc
Session ii g3 overview epidemiology modeling mmcSession ii g3 overview epidemiology modeling mmc
Session ii g3 overview epidemiology modeling mmc
USD Bioinformatics
 
MathematicallyModelingEpidemicsThroughtheUseoftheReed-FrostEquation
MathematicallyModelingEpidemicsThroughtheUseoftheReed-FrostEquationMathematicallyModelingEpidemicsThroughtheUseoftheReed-FrostEquation
MathematicallyModelingEpidemicsThroughtheUseoftheReed-FrostEquation
Alexander Kaunzinger
 
F0623642
F0623642F0623642
F0623642
IOSR Journals
 
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
IOSR 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 Jakubovic
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
amiteksecurity
 
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
jkcs20004
 
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
AdhyaDubey1
 
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
Wouter 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 DISEASES
SOUMYADAS835019
 
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
 
Schwab_Thesis
Schwab_ThesisSchwab_Thesis
Schwab_Thesis
Henry Schwab
 
Al04606233238
Al04606233238Al04606233238
Al04606233238
IJERA Editor
 
Sample, disease modeling vzv
Sample, disease modeling vzvSample, disease modeling vzv
Sample, disease modeling vzv
KellieWatkins1
 
Epidemiological modelling
Epidemiological modellingEpidemiological modelling
Epidemiological modelling
Sumit Das
 
Sir presentation
Sir presentationSir presentation
Sir presentation
LabartinosAllan
 
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
Andino Maseleno
 

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

Session ii g3 overview epidemiology modeling mmc
Session ii g3 overview epidemiology modeling mmcSession ii g3 overview epidemiology modeling mmc
Session ii g3 overview epidemiology modeling mmc
 
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
 

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++.pdf
snewfashion
 
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
snewfashion
 
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
snewfashion
 
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
snewfashion
 
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
snewfashion
 
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
snewfashion
 
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
snewfashion
 
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
snewfashion
 
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
snewfashion
 

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

LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
RAHUL
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
paigestewart1632
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
sayalidalavi006
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 

Recently uploaded (20)

LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 

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.