moving_average()

Returns the moving_average of a sequence of data

Syntax
y = moving_average(Data, NumPoints)

Arguments
Name Description Range Type Required
Data one or multi-dimensional sequence of numbers (-∞, ∞) integer, real or complex yes
NumPoints Number of points to be averaged together [1, ∞) † integer yes
† NumPoints must be an odd number. If even, the value is increased to the next odd number. If greater or equal to the number of data points, the value is set to number of data points - 1 for even number of data points. For odd number of data points, NumPoints is set to number of data points

Examples

a = moving_average([1, 2, 3, 7, 5, 6, 10], 3)
returns [1, 2, 4, 5, 6, 7, 10]

Defined in

Built in

Notes/Equations

The first value of the smoothed sequence is the same as the original data. The second value is the average of the first three. The third value is the average of data elements 2, 3, and 4, etc. If NumPoints were set to 7, for example, then the first value of the smoothed sequence would be the same as the original data. The second value would be the average of the first three original data points. The third value would be the average of the first five data points, and the fourth value would be the average of the first seven data points. Subsequent values in the smoothed array would be the average of the seven closest neighbors. The last points in the smoothed sequence are computed in a way similar to the first few points. The last point is just the last point in the original sequence. The second from last point is the average of the last three points in the original sequence. The third from the last point is the average of the last five points in the original sequence, etc.

 

Privacy Statement  | Terms of Use  | Legal | Contact Us  | © Agilent 2000-2008 

Contents
Additional Resources