(10) |

(11) |

subroutine boxconv( nb, nx, xx, yy) # inputs: nx, xx(i), i=1,nx the data # nb the box length # output: yy(i),i=1,nx+nb-1 smoothed data integer nx, ny, nb, i real xx(nx), yy(1) temporary real bb(nx+nb) if( nb < 1 || nb > nx) call erexit('boxconv') # "||" means .OR. ny = nx+nb-1 do i= 1, ny bb(i) = 0. bb(1) = xx(1) do i= 2, nx bb(i) = bb(i-1) + xx(i) # make B(Z) = X(Z)/(1-Z) do i= nx+1, ny bb(i) = bb(i-1) do i= 1, nb yy(i) = bb(i) do i= nb+1, ny yy(i) = bb(i) - bb(i-nb) # make Y(Z) = B(Z)*(1-Z**nb) do i= 1, ny yy(i) = yy(i) / nb return; endIts last line scales the output by dividing by the rectangle length. With this scaling, the zero-frequency component of the input is unchanged, while other frequencies are suppressed.

Let us examine the pole and zero locations
in equation (10).
The denominator vanishes at *Z*=1, so the filter has a pole at zero frequency.
Smoothing something is like boosting frequencies near the zero frequency.
The numerator vanishes at the five roots of unity,
i.e., .These five locations are uniformly spaced around the unit circle.
Any sinusoid at exactly one of these frequencies is exactly destroyed
by this filter,
because such a sinusoid has an integer number of wavelengths under the boxcar.
An exception is the zero frequency, where the root at *Z*=1
is canceled by a pole at the same location.
This cancellation is the reason the right-hand side ends
at the fourth power--there is no infinite series of higher powers.

10/21/1998