Question: Problem 1 1 : Smoothing Data When data is temporal ( ordered by time ) , we sometimes want to smooth it by giving

Problem 11: Smoothing Data
When data is temporal (ordered by time), we sometimes want to smooth" it by giving a simple
average. The simplest is taking two consecutive values and finding their average. Given a
(possibly empty) list of numbers lst =[x0,x1,...,xn] the function smooth(lst) returns:
The string AveError: list empty" if the list is empty
lst if list only contains one number
a new list of numbers [y0,y1,...,yn1] such that yi =
xi+xi+1
2
The following code
1 data =[[],[1],[1,2],[1,2,2,3],[0,2,4,6,8]]
2 for d in data :
3 print ( smooth ( d ))
produces
1 AveError : list empty
2[1]
3[1.5]
4[1.5,2.0,2.5]
5[1.0,3.0,5.0,7.0]
Deliverables for Problem 11
Complete the function.
Round to two decimal places.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!