Practice problems

| categories: Practice

Try programming these before class on Friday.

Define an exponential smoothing filter that takes an array of numbers and a smoothing factor alpha and produces a new smoothed array. You should be able to call your function like this: B = esmooth(A, alpha)

With your result in R and the input array A, R[0] should equal A[0] and R[i] (for i > 0) should equal alpha*A[i] + (1 - alpha)*R[i-1]. Use a loop to compute the values of R[i].


Define another function bdesmooth(A, alpha) that does bidirectional exponential smoothing by using esmooth to filter the array A forward and backward (by reversing A before handing it to esmooth and reversing the result) and then averaging the two results together.


Define a function that replaces outliers in an array A with the mean of the inliers. Your function should accept the array A and a pair of numbers that define the range of the inliers (their min and max).