Nonrecursive filters

Syntax: FILTER\-RECURSIVE x f c

If the \-RECURSIVE qualifier is used, the third parameter, c, must be a vector. The data array, x, is processed through a nonrecursive filter using the values of c as the data coefficients:

where   is the length of vector c. Note that when c has an even number of elements, the filter will be applied to the   point by application to points from   to  . For example, when   is two, the weightings will be applied to the previous point and to the current point.

Differentiating nonrecursive filters

Remember, that the x's must be equally spaced, and are actually assumed by the FILTER command to have unit spacing. Thus, to obtain the correct output scaling, multiply f by , where   is the order of the derivative,   is the length of vector c, and   is the spacing of x, that is, . For example:

 FILTER\-RECURSIVE X XOUT [2;-16;0;16;-2]  ! 1st deriv. nonrecursive filter
 XOUT=XOUT/(24*(X[2]-X[1]))                ! use scale factor 1/(h*4!)
 

See Table 1 for various first derivative nonrecursive filter data coefficients. See Table 2 for various second derivative nonrecursive filter data coefficients. See Table 3 for various third derivative nonrecursive filter data coefficients.

Table 1:   Various 1st derivative nonrecursive filters
type data coefficients scale factor
3 point   [ 1; 0; -1 ]  1/2h 
4 point   [ 1; -6; 3; 2 ]  1/6h 
5 point   [ 2; -16; 0; 16; -2 ]  1/24h 
6 point   [ -4; 30; -120; 40; 60; -6 ]  1/120h 

Table 2:   Various 2nd derivative nonrecursive filters
type data coefficients scale factor
3 point   [ 1; -2; 1 ]  1/h2 
4 point   [ 0; 3; -6; 3 ]  1/3h2 
5 point   [ -1; 16; -30; 16; -1 ]  1/12h2 
6 point   [ 0; 5; 80; -150; 80; -5 ]  1/60h2 

Table 3:   Various 3rd derivative nonrecursive filters
type data coefficients scale factor
4 point   [ -1; 3; -3; 1 ]  1/h3 
5 point   [ -2; 4; 0; -4; 2 ]  1/4h
6 point   [ 5; -35; 70; -50; 5; 5 ]  1/20h3 

Smoothing nonrecursive filters

See Table 4 for various quadratic smoothing nonrecursive filter data coefficients. See Table 5 for various quartic smoothing nonrecursive filter data coefficients. See Table 6 for Spencer's formulae smoothing nonrecursive filter data coefficients.

Table 4:   Smoothing nonrecursive filters (quadratic)
type data coefficients scale factor
5 point   [ -3; 12; 17; 12; -3 ]  1/35 
7 point   [ -2; 3; 6; 7; 6; 3; -2 ]  1/21 
9 point   [ -21; 14; 39; 54; 59; 54; 39; 14; -21 ]  1/231 
11 point   [ -36; 9; 44; 69; 84; 89; 84; 69; 44; 9; -36 ]  1/429 

Table 5:   Smoothing nonrecursive filters (quartic)
type data coefficients scale factor
7 point   [ 5; -30; 75; 131; 75; -30; 5 ]  1/231 
9 point   [ 15; -55; 30; 135; 179; 135; 30; -55; 15 ]  1/429 
11 point   [ 18; -45; -10; 60; 120; 143; 120; 60; -10; -45; 18 ]  1/429 
13 point   [ 110; -198; -135; 110; 390; 600; 677; 600; 390; 110; -135; -198; 110 ]  1/2431 

Table 6:   Smoothing nonrecursive filters (Spencer's formulae)
type data coefficients scale factor
15 point   [ -3; -6; -5; 3; 21; 46; 67; 74; 67; 46; 21; 3; -5; -6; -3 ]  1/320 
21 point   [ -1; -3; -5; -5; -2; 6; 18; 33; 47; 57; 60; 57; 47; 33; 18; 6; -2; -5; -5; -3; -1 ]  1/350 

Interpolating nonrecursive filters

Suppose we have points in a vector which are "bad" and need to be replaced. Assuming one can fit the data with an odd degree polynomial. The next higher order difference equation, when set to zero, can be used to give the desired filter coefficients. For example, if the data can be fit with a 5th order polynomial, the fourth difference set to zero gives:

and solving for   gives:

so the data filter coefficients are [ -1/6; 2/3; 0; 2/3; -1/6 ].

  Mean filters
  Recursive filters