Question: python 2. Sample values from an experiment often need to be smoothed out. One approach is to replace each value with the mean of the
2. Sample values from an experiment often need to be smoothed out. One approach is to replace each value with the mean of the previous n values, this is called the simple moving average. Implement a function def smooth(values, n) that carries out this operation. The variable values is a list and n is the size of the moving average. The function should return a new list with the smoothed data. The new list should have n - 1 fewer elements than the original list. For example, given the list (3, 5, 1, 5, 6, 8, 9, 10, 15, 3] and n=3, the function should return (3.0, 3.6, 4.0, 6.3, 7.6, 9.0, 11.3, 9.3]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
