Question
[PLEASE using like ATOPM editor or Using like this webpage https://paste.ee/p/9QcVt because I cannot recognize your answer correctly! Thank you!] Exercise 3a A list of
[PLEASE using like ATOPM editor or Using like this webpage https://paste.ee/p/9QcVt because I cannot recognize your answer correctly! Thank you!]
Exercise 3a
A list of numbers can be very unsmooth, meaning very high numbers can be right next to very low numbers. This list may represent a smooth path in reality that is masked with random noise (for example, satellite trajectories with inaccurate transmission). One way to smooth the values in the list is to replace each value with the average of each value's neighbors, including the value itself.
#Write a function moving_window_average(x, n_neighbors) that takes a list x and the number of neighbors n_neighbors on either side of a given member of the list to consider.
#For each value in x, moving_window_average(x, n_neighbors) computes the average of that value's neighbors, where neighbors includes the value itself.
#moving_window_average should return a list of averaged values that is the same length as the original list.
#If there are not enough neighbors (for cases near the edge), substitute the original value as many times as there are missing neighbors.
#Use your function to find the moving window sum of x=[0,10,5,3,1,5] and n_neighbors=1.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started