Impulse Response of a Moving Average System

According to Discrete Time Signal Processing by Al Oppenheim 3rd Edition, the impulse response of a moving average filter is as below

My question is that shouldn't h[n] be having the dirac delta function instead of the unit function u[n] (See Eq 2.9). This is mentioned in example 2.3 of the same book

• It shouldn't be too surprising that there are several equivalent representations of the same impulse response. Just draw the impulse response and make sure you can see how these two representations are equivalent. – Matt L. Nov 26 '19 at 7:51

Your confusion should be removed away when you consider the fact that the following signals are the same :

$$u[n] - u[n-3] ~ = ~ \delta[n] + \delta[n-1] + \delta[n-2]$$

or generalizing for any integer $$M$$: $$u[n] - u[n-M] = \delta[n] + \delta[n-1] +...+ \delta[n-M+1] = \sum_{k=0}^{M-1} \delta[n-k]$$

or even further for $$K < M$$ $$u[n-K] - u[n-M] = \sum_{k=K}^{M-1} \delta[n-k]$$

Taking Equation $$2.74$$ from Example $$3$$ and setting $$M_1=0$$ gives:

$$h[n] = \frac{1}{M_2+1} \sum_{k=0}^{M_2} \delta[n-k]$$

Now lets take a closer look at this: $$h[n]$$ is non-zero only for certain values of $$n$$. Its a good a starting point as any, so lets look at $$n=0$$. We have:

$$h[0] = \frac{1}{M_2+1} \bigg( \delta[0] + \delta[-1] + ... + \delta[-M_2] \bigg) = \frac{1}{M_2+1}$$

For $$n=1$$, we have:

$$h[1] = \frac{1}{M_2+1} \bigg( \delta[1] + \delta[0] + ... + \delta[1-M_2] \bigg) = \frac{1}{M_2+1}$$

For $$n=2$$, we have:

$$h[2] = \frac{1}{M_2+1} \bigg( \delta[-2] + \delta[-1] + \delta[0]+ ... + \delta[2-M_2] \bigg) = \frac{1}{M_2+1}$$

And this pattern continues, the only non-zero value $$\delta[0]$$ percolates through until $$n=M_2$$, then we have:

$$h[M_2] = \frac{1}{M_2+1} \bigg( \delta[-M_2] + \delta[-M_2+1] + ... + \delta[0] \bigg) = \frac{1}{M_2+1}$$

And for $$n = M_2 + 1$$:

$$h[M_2+1] = \frac{1}{M_2+1} \bigg( \delta[-M_2-1] + \delta[-M_2] + ... + \delta[-1] \bigg) = 0$$

And you can see, for all $$n > M_2$$, $$h[n]=0$$. So, altogether we can write $$h[n]$$ as equal to $$\frac{1}{M_2+1}$$ for $$n \in [0, M_2]$$ and zero otherwise.

All Equation $$2.90$$ does is treats the summation of impulses (from Equation $$2.74$$) as unit step functions, a very useful trick! Since $$h[n]$$ starts at $$n=0$$ and ends at $$n=M_2$$ we do: $$u[n]-u[n-M_2-1]$$ to get a length $$M_2$$ box car, then scale it by $$\frac{1}{M_2+1}$$ to get the right amplitude. Hope this helps!