enter image description here

My professor threw in the random term and never explained what it means cus he's been going on strike for 3 weeks straight.


2 Answers 2


Let us forget about filters for a moment, and think of their action as a weighted average or the computation of a center of mass. Let us fix the filter to be of length $N=3$, and call the weights $(w_1,w_2,w_3)$. There are several options in applying the weights to a signal $x[n]$ to get a filtered version $y[n]$. From the slides, I guess that the semi-infinite is a kind of causal online version. In simpler word: at index $k$, you get $x[k]$ and you obtain $y[k]$ by performing a weighted average of the last three values of $x$, including the last obtained.

Therefore, the last three values should be $(x[n-2],x[n-1],x[n])$, and you would like to compute:

$$y[n] = w_1 x[n-2]+w_2x[n-1]+w_3x[n]\,.$$

What happens then when:

  • $n=1$: this first sample is the first, there is no $x$ defined before, so $x[n-1]=x[1-1]=x[0]$ and $x[n-2]=x[1-2]=x[-1]$ have no meaning, and we don't use the values $w_1$ and $w_2$. We get $y[1] = w_3x[1]$
  • $n=2$: this is the second sample, so the first one exists before. So $x[n-1]=x[2-1]=x[1]$ has a meaning, but not and $x[n-2]=x[2-2]=x[0]$. So we can compute $y[2] = w_2x[1]+w_3x[2]$ and we don't use $w_1$.
  • $n=3$: now all is good, we have enough samples before $x[2]$ to use all the weights, and $y[3] = w_1 x[1]+w_2x[2]+w_3x[3]\,.$

Now, for all $n\ge 3$, the last situation happens, and we have enough samples to perform a full weighted average, until the end of $y[n]$. Finally, you have incomplete weighting for $n\le 2$, hence a edge effect, and no more after that. The above reasoning works accordingly for other filter lengths.

Nota: techniques to overcome this issue consist in providing regular extensions to the signal when it is unknown (as said in another answer) or adapt the filter length to make it shorter on the indices at the beginning.

  • 1
    $\begingroup$ thank you so much for spending time explaining from the ground up. I didn't realize it was this easy. $\endgroup$ Mar 8, 2022 at 1:52
  • $\begingroup$ Good! If you feel like it, do not hesitate to vote and accept the answer $\endgroup$ Mar 8, 2022 at 3:34
  • 1
    $\begingroup$ I have accepted your answer but couldn't vote for yours tho. Apparently, I need 15 reputations $\endgroup$ Mar 9, 2022 at 9:22
  • $\begingroup$ Good, And patience $\endgroup$ Mar 9, 2022 at 10:39

When theory and solutions assume an infinite sequence, and you apply that solution to a finite sequence, you get «discrepancies» at the start and/or end.

For a lowpass filter/smoother that may be that the internal filter states cannot be filled because the relevant data does not exist.

You can try to «hide» this by hacking the state to satisfy some continuity requirement.

Or you can simply omitt the output along the edge. Like your example seems to do.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.