AVGFILT

Purpose:

Filters a series using the average of the N neighboring points.

Syntax:

AVGFILT(series, N, gval, lval)

series

-

An input series or table.

N

-

Optional. An integer, the number of neighbors to average. For point i, average points i-N through i+N exclusive of point i. Defaults to 1, i.e. for point i, average points i-1 and i+1

gval

-

Optional. A real, the "greater than" threshold at which to replace a point. Point i is replaced if: point[i] > gval * current average[i]. Defaults to 1.0, i.e. replace each point if it is greater than the average of the neighbors.

lval

-

Optional. A real, the "less than" threshold at which to replace a point. Point i is replaced if: point[i] < lval * current average[i]. Defaults to unspecified, i.e. do not use a "lesser than" threshold.

Returns:

A series.

Example:

W1: gnorm(100,.01)

W2: avgfilt(W1)

 

replaces each point of W1 with the average of the previous and next point if it exceeds the average.

Example:

W3: avgfilt(W1, 2)

 

replaces each point of W1 with the average of the two previous and two next points if it exceeds the average.

Example:

W3: avgfilt(W1, 1, 1.2)

 

replaces each point of W1 with the average of the previous and next point if it exceeds the average by 20%.

Example:

W4: avgfilt(W1, 1, 1.2, 1.3)

 

replaces each point of W1 with the average of the previous and next point if it exceeds the average by 20% or is less than the average by 30%.

Example:

W5: avgfilt(W1, 1, 0, 0)

 

replaces each point of W1 with the average of the previous and next point unconditionally.

Example:

W6: -avgfilt(-W1, 1, 1.2)

 

replaces each point of W1 with the average of the previous and next point if it is less than the average by 20%.

Remarks:

AVGFILT uses the convolution function to calculate the neighbor averages. For N == 1, the kernel is simply: {1, 0, 1} / 2

 

See BLOCKAVG to compute a simple N point non-overlapping moving average.

See Also:

BLOCKAVG

CONV

EXPMOVAVG

LINAVG

MOVAVG