Assignment 4

Solution

Important dates

Assigned20 Mar 2017 @ 21:45h
Due27 Mar 2017 @ 23:59h

Description

Implement a function to calculate the moving average of some data.

The moving average of a sequence of data points is, for each point in the sequence, the average of the last $n$ values. Taking the moving average of a function smooths out the data, which can be useful when visualizing data or performing various analyses. Applying a moving average to an audio signal removes high-pitched sounds; averaging image data creates an out-of-focus or “blur” effect.

Moving averages can be weighted in different ways, but for this assignment your goal is to implement a function that computes a simple moving average. To do this, you will need to use arrays and loops. I strongly suggest that you work through the design of your algorithm before sitting down to write code.

You should submit a file entitled assign4.cpp that contains the definition of a function called movingAverage as declared in assign4.h. Your source file may contain a main function for your own testing, but is not required to. Your movingAverage definition must exactly match the declaration in assign4.h. This header file is also visible below: