SlideShare una empresa de Scribd logo
1 de 1
Descargar para leer sin conexión
Often when visualizing time-series data, it makes sense to look not at day-by-day changes, but
rather at a 7 -day rolling average. For example, when looking at Covid-19 cases, there are
reporting fluctuations from day to day, so instead it is usually better to look at the average number
of cases over the previous 7 days. Write a function def rolling( A, windowe7): which takes as input
a one-dimensional numpy array A, and a parameter window whose default value is 7. The function
must retum an array R whose length is shorter than the length of A. The entry R[] should be the
average of A[J]. A[j+1], etc, up to A[j+window1]. Then use this function and matplotib to produce a
plot: a line plot of the array A produced below, and a line plot of the 7 -day rolling average R
produced by your function. These plots should be on the same figure, and clearly labeled. [] " Here
is the code to produce your test array A. II Please use this array in your ploti x _array = np-
arange(3ee) A=5(x_array/200)24 Please use this code to inport anatiotilb. inport natplotilbapyplot
as plt I [ ] Were is a plot of the array, to get you started. plt.plot (xarray,A) [ ]

Más contenido relacionado

Similar a Often when visualizing timeseries data it makes sense to l.pdf

CSCI 2033 Elementary Computational Linear Algebra(Spring 20.docx
CSCI 2033 Elementary Computational Linear Algebra(Spring 20.docxCSCI 2033 Elementary Computational Linear Algebra(Spring 20.docx
CSCI 2033 Elementary Computational Linear Algebra(Spring 20.docx
mydrynan
 
2D & 3D Modelling with Mathematica
2D & 3D Modelling with Mathematica2D & 3D Modelling with Mathematica
2D & 3D Modelling with Mathematica
Miles Ford
 
Functions & Procedures [7]
Functions & Procedures [7]Functions & Procedures [7]
Functions & Procedures [7]
ecko_disasterz
 

Similar a Often when visualizing timeseries data it makes sense to l.pdf (19)

Lar calc10 ch03_sec6
Lar calc10 ch03_sec6Lar calc10 ch03_sec6
Lar calc10 ch03_sec6
 
RBD-Demo
RBD-DemoRBD-Demo
RBD-Demo
 
R programming slides
R  programming slidesR  programming slides
R programming slides
 
Lecture 1 mte 407
Lecture 1 mte 407Lecture 1 mte 407
Lecture 1 mte 407
 
Lecture 1 mte 407
Lecture 1 mte 407Lecture 1 mte 407
Lecture 1 mte 407
 
Numerical analysis using Scilab: Numerical stability and conditioning
Numerical analysis using Scilab: Numerical stability and conditioningNumerical analysis using Scilab: Numerical stability and conditioning
Numerical analysis using Scilab: Numerical stability and conditioning
 
R studio
R studio R studio
R studio
 
Scilab as a calculator
Scilab as a calculatorScilab as a calculator
Scilab as a calculator
 
educational course/tutorialoutlet.com
educational course/tutorialoutlet.comeducational course/tutorialoutlet.com
educational course/tutorialoutlet.com
 
R9
R9R9
R9
 
Cs291 assignment solution
Cs291 assignment solutionCs291 assignment solution
Cs291 assignment solution
 
CSCI 2033 Elementary Computational Linear Algebra(Spring 20.docx
CSCI 2033 Elementary Computational Linear Algebra(Spring 20.docxCSCI 2033 Elementary Computational Linear Algebra(Spring 20.docx
CSCI 2033 Elementary Computational Linear Algebra(Spring 20.docx
 
2D & 3D Modelling with Mathematica
2D & 3D Modelling with Mathematica2D & 3D Modelling with Mathematica
2D & 3D Modelling with Mathematica
 
Project
ProjectProject
Project
 
5.2 Least Squares Linear Regression.pptx
5.2  Least Squares Linear Regression.pptx5.2  Least Squares Linear Regression.pptx
5.2 Least Squares Linear Regression.pptx
 
Chapter 18,19
Chapter 18,19Chapter 18,19
Chapter 18,19
 
Regression analysis in excel
Regression analysis in excelRegression analysis in excel
Regression analysis in excel
 
Functions & Procedures [7]
Functions & Procedures [7]Functions & Procedures [7]
Functions & Procedures [7]
 
Regression diagnostics - Checking if linear regression assumptions are violat...
Regression diagnostics - Checking if linear regression assumptions are violat...Regression diagnostics - Checking if linear regression assumptions are violat...
Regression diagnostics - Checking if linear regression assumptions are violat...
 

Más de advancethchnologies

oklu ve ldrc aleller neden klasik Mendel monohibrit ve .pdf
oklu ve ldrc aleller neden klasik Mendel monohibrit ve .pdfoklu ve ldrc aleller neden klasik Mendel monohibrit ve .pdf
oklu ve ldrc aleller neden klasik Mendel monohibrit ve .pdf
advancethchnologies
 

Más de advancethchnologies (20)

On day 1 of the menstrual cycle FSH levels will be 25 pts .pdf
On day 1 of the menstrual cycle FSH levels will be 25 pts .pdfOn day 1 of the menstrual cycle FSH levels will be 25 pts .pdf
On day 1 of the menstrual cycle FSH levels will be 25 pts .pdf
 
On August 2 1971 Commander Scott of Apollo 15 confirmed Ga.pdf
On August 2 1971 Commander Scott of Apollo 15 confirmed Ga.pdfOn August 2 1971 Commander Scott of Apollo 15 confirmed Ga.pdf
On August 2 1971 Commander Scott of Apollo 15 confirmed Ga.pdf
 
On April 1 2024 Ivanhoe Company purchased 41600 common sh.pdf
On April 1 2024 Ivanhoe Company purchased 41600 common sh.pdfOn April 1 2024 Ivanhoe Company purchased 41600 common sh.pdf
On April 1 2024 Ivanhoe Company purchased 41600 common sh.pdf
 
On any given day the probability that Marco eats sushi for .pdf
On any given day the probability that Marco eats sushi for .pdfOn any given day the probability that Marco eats sushi for .pdf
On any given day the probability that Marco eats sushi for .pdf
 
Objective Draw the data path and interface with the control.pdf
Objective Draw the data path and interface with the control.pdfObjective Draw the data path and interface with the control.pdf
Objective Draw the data path and interface with the control.pdf
 
On a certain island there is a population of snakes foxes.pdf
On a certain island there is a population of snakes foxes.pdfOn a certain island there is a population of snakes foxes.pdf
On a certain island there is a population of snakes foxes.pdf
 
Omnichannel retailing is A when a retailer either closes .pdf
Omnichannel retailing is A when a retailer either closes .pdfOmnichannel retailing is A when a retailer either closes .pdf
Omnichannel retailing is A when a retailer either closes .pdf
 
Omigo On a Mission to Create a Bidet Culture in the United .pdf
Omigo On a Mission to Create a Bidet Culture in the United .pdfOmigo On a Mission to Create a Bidet Culture in the United .pdf
Omigo On a Mission to Create a Bidet Culture in the United .pdf
 
Olfactory receptor cells and auditory receptors share the fo.pdf
Olfactory receptor cells and auditory receptors share the fo.pdfOlfactory receptor cells and auditory receptors share the fo.pdf
Olfactory receptor cells and auditory receptors share the fo.pdf
 
Olivia a oneyearold infant is brought to the emergency r.pdf
Olivia a oneyearold infant is brought to the emergency r.pdfOlivia a oneyearold infant is brought to the emergency r.pdf
Olivia a oneyearold infant is brought to the emergency r.pdf
 
Okul andaki nfusun yzde on drd zel okullara gidiyor ve.pdf
Okul andaki nfusun yzde on drd zel okullara gidiyor ve.pdfOkul andaki nfusun yzde on drd zel okullara gidiyor ve.pdf
Okul andaki nfusun yzde on drd zel okullara gidiyor ve.pdf
 
oklu ve ldrc aleller neden klasik Mendel monohibrit ve .pdf
oklu ve ldrc aleller neden klasik Mendel monohibrit ve .pdfoklu ve ldrc aleller neden klasik Mendel monohibrit ve .pdf
oklu ve ldrc aleller neden klasik Mendel monohibrit ve .pdf
 
Okuyucunun trevleri anladn ve anlk hzn dxdt tanmn bildii.pdf
Okuyucunun trevleri anladn ve anlk hzn dxdt tanmn bildii.pdfOkuyucunun trevleri anladn ve anlk hzn dxdt tanmn bildii.pdf
Okuyucunun trevleri anladn ve anlk hzn dxdt tanmn bildii.pdf
 
okay ment rebuild the project what is the first ertor you g.pdf
okay ment rebuild the project what is the first ertor you g.pdfokay ment rebuild the project what is the first ertor you g.pdf
okay ment rebuild the project what is the first ertor you g.pdf
 
ok hcre saln destekleyen oksijenin verilmesi ve gereksinim.pdf
ok hcre saln destekleyen oksijenin verilmesi ve gereksinim.pdfok hcre saln destekleyen oksijenin verilmesi ve gereksinim.pdf
ok hcre saln destekleyen oksijenin verilmesi ve gereksinim.pdf
 
Office Automation Inc developed a proposal for implementin.pdf
Office Automation Inc developed a proposal for implementin.pdfOffice Automation Inc developed a proposal for implementin.pdf
Office Automation Inc developed a proposal for implementin.pdf
 
Of the 214 million US firms without paid employees 32 a.pdf
Of the 214 million US firms without paid employees 32 a.pdfOf the 214 million US firms without paid employees 32 a.pdf
Of the 214 million US firms without paid employees 32 a.pdf
 
Of the following which is NOT true about the service econom.pdf
Of the following which is NOT true about the service econom.pdfOf the following which is NOT true about the service econom.pdf
Of the following which is NOT true about the service econom.pdf
 
Of the following which is the biggest risk factor for the d.pdf
Of the following which is the biggest risk factor for the d.pdfOf the following which is the biggest risk factor for the d.pdf
Of the following which is the biggest risk factor for the d.pdf
 
Of the four universal forces strong weak electromagnetic.pdf
Of the four universal forces strong weak electromagnetic.pdfOf the four universal forces strong weak electromagnetic.pdf
Of the four universal forces strong weak electromagnetic.pdf
 

Último

Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

Último (20)

Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 

Often when visualizing timeseries data it makes sense to l.pdf

  • 1. Often when visualizing time-series data, it makes sense to look not at day-by-day changes, but rather at a 7 -day rolling average. For example, when looking at Covid-19 cases, there are reporting fluctuations from day to day, so instead it is usually better to look at the average number of cases over the previous 7 days. Write a function def rolling( A, windowe7): which takes as input a one-dimensional numpy array A, and a parameter window whose default value is 7. The function must retum an array R whose length is shorter than the length of A. The entry R[] should be the average of A[J]. A[j+1], etc, up to A[j+window1]. Then use this function and matplotib to produce a plot: a line plot of the array A produced below, and a line plot of the 7 -day rolling average R produced by your function. These plots should be on the same figure, and clearly labeled. [] " Here is the code to produce your test array A. II Please use this array in your ploti x _array = np- arange(3ee) A=5(x_array/200)24 Please use this code to inport anatiotilb. inport natplotilbapyplot as plt I [ ] Were is a plot of the array, to get you started. plt.plot (xarray,A) [ ]