# Can I construct a linear system so that it results in a moving average?

I've just learned about linear systems and impulse response functions. I know that in a linear system consisting of $h_1[k]$ and $h_2[k]$, the impulse response of the system is $h_1[k] \ast h_2[k]$.

In an exercise I was given the following system responses:

\begin{align*} h_1(0) &= a \\ h_1(1) &= b \\ h_2(0) &= c \\ h_2(1) &= d \\ h_1(n) = h_2(n) &= 0 \; \text{otherwise} \\ \end{align*}

The question was whether it would be possible to construct the parameters $a$, $b$, $c$, and $d$ in such a way that the linear system $h_1 \ast h_2$ would result in a moving average of the order 3 being applied to the input.

Well, I started with the convolution $h[k] = h_1[k] \ast h_2[k]$ for $k = 0, 1$:

\begin{equation} h[k] = [ac, bc + ad, bd] \end{equation}

I understand that for a moving average of order 3, the required convolution kernel would look like this:

\begin{equation} [1/3, 1/3, 1/3] \end{equation}

But that means I have to solve the following equation:

\begin{align*} ac &= 1/3 \\ bc + ad &= 1/3 \\ bd &= 1/3 \\ \end{align*}

And that's where I'm stuck. From my guts I'd say it's not possible to get to an answer here, because even if $a = 1$ and $b = 1$, $c$ and $d$ would have to be $1/3$ and $c + d$ would have to be $1/3$ as well. Which isn't solvable.

• i don't have time to answer this question, but clearly you can make an FIR with 3 taps and coefficients all equal to $\frac{1}{3}$. for longer moving average filters (like the moving average of 200 adjacent samples), there is the commonly known CIC filter method that is really a filter in this class we sometimes call "Truncated IIR filters" (TIIR). you can do a moving average filter without any complex states or complex coefficients. dunno why that came up. Jan 10, 2014 at 2:18

The function you are trying to solve is equivalent to $$\frac{b}{3 \cdot a} + \frac{a}{3 \cdot b}=\frac{1}{3}$$

It is also $$a^2-ab+b^2=0$$

but this function does not have a real number solution.

• You can also use Wolfram Alpha to analyze the system of equations. As lennon310 pointed out, there are no real solutions. Jan 9, 2014 at 17:21
• Note that a complex solution requires a filter with a complex state to implement. A complex state has two degrees of freedom, which might be able to encode both the current magnitude and the amount to subtract off the back end of a moving average approximation. Jan 9, 2014 at 18:31
• a=1;b=0.5*(1-1*isqrt(3));c=1/3;d=(1 + isqrt(3))/6; conv([a b],[c d]) ans = 0.3333 0.3333 0.3333
– John
Jan 9, 2014 at 18:46

The gain of the desired moving average filter is not important; you can stick it after you have done the important work, if you like. What you are asking is whether $G(z)H(z) = (a +bz^{-1})(c + dz^{-1})$ can equal $(1 + z^{-1} + z^{-2})$. Unfortunately, the roots of $1+z^{-1}+z^{-2}$ are the two complex cube roots of unity, that is, $$1 + z^{-1} + z^{-2} = \left(1+e^{j2\pi/3}z^{-1}\right)\left(1+e^{j4\pi/3}z^{-1}\right)$$and so the only way this is going to work is if we allow the coefficients to be complex numbers.

• So, with regard to the assignment, do you think there's anything I'm supposed to "find out" except the fact that it's not possible to solve in the real numbers (which I sort of already did)? Any bigger picture? Oh, and what's the special meaning of $j$ if I may ask? Jan 11, 2014 at 10:03
• "Oh, and what's the special meaning of $j$ if I may ask?" On this forum, $j$ almost always means the square root of $-1$ (mathematicians use $i$ for this entity) as for example in the factorization that I show in my answer. Thus, it is a very bad idea to use $j$ to denote an integer-valued variable or index of summation, etc. Jan 11, 2014 at 11:44