What Is the Best First Order IIR (AR Filter) Approximation to a Moving Average Filter (FIR Filter)?
OK, let's try to derive the best:
$$
\begin{array}{lcl}
y[n] &amp;=&amp; \alpha x[n] + (1 - \alpha) y[n - 1] \\
&amp;=&amp;  \alpha x[n] + (1 - \alpha) \alpha x[n-1] + (1 - \alpha)^2 y[n - 2]\\
&amp;=&amp;  \alpha x[n] + (1 - \alpha) \alpha x[n-1] + (1 - \alpha)^2 \alpha x[n-2] + (1 - \alpha)^3 y[n - 3]\\
\end{array}
$$
so that the coefficient of $x[n-m]$ is $\alpha(1-\alpha)^m$.

The best mean-square approximation will minimize:
$$
\begin{array}{lcl}
J(\alpha) &amp;=&amp; \sum_{m=0}^{k-1} (\alpha(1-\alpha)^m - \frac{1}{k})^2 + \sum_{m=k}^\infty \alpha^2(1-\alpha)^{2m}\\
&amp;=&amp; \sum_{m=0}^{k-1} \left(\alpha^2(1-\alpha)^{2m} - \frac{2}{k}\alpha(1-\alpha)^m + \frac{1}{k^2}\right) + \alpha^2 (1-\alpha)^{2k} \sum_{m=0}^\infty (1-\alpha)^{2m} \\
&amp;=&amp; \alpha^2\frac{1- (1-\alpha)^{2k}}{1 - (1-\alpha)^2} + \frac{2\alpha}{k} \frac{1 - (1 - \alpha)^k}{1 - (1 - \alpha)} + \frac{\alpha^2(1-\alpha)^{2k}}{1 - (1 - \alpha)^2}+ \frac{1}{k}\\
&amp;=&amp; \frac{\alpha^2}{1 - (1 - \alpha)^2} + \frac{2}{k} (1-(1-\alpha)^k) + \frac{1}{k}\\
&amp;=&amp; \frac{\alpha^2}{2\alpha - \alpha^2 }+ \frac{2}{k} (1-(1-\alpha)^k)+ \frac{1}{k}\\
&amp;=&amp; \frac{\alpha}{2 - \alpha }+ \frac{2}{k} (1-(1-\alpha)^k)+ \frac{1}{k}\\
\end{array}
$$
because the FIR coefficients are zero for $m &gt; k - 1$.

Next step is to take derivatives and equate to zero.



Looking at a plot of the derived $J$ for $K = 1000$ and $\alpha$ from 0 to 1, it looks like the problem (as I've set it up) is ill-posed, because the best answer is $\alpha = 0$.





I think there's a mistake here.
The way it should be according to my calculations is:

$$
\begin{array}{lcl}
J(\alpha) &amp;=&amp; \sum_{m=0}^{k-1} (\alpha(1-\alpha)^m - \frac{1}{k})^2 + \sum_{m=k}^\infty \alpha^2(1-\alpha)^{2m} \\
&amp;=&amp; \sum_{m=0}^{k-1} \left(\alpha^2(1-\alpha)^{2m} - \frac{2}{k}\alpha(1-\alpha)^m + \frac{1}{k^2}\right) + \alpha^2 (1-\alpha)^{2k} \sum_{m=0}^\infty (1-\alpha)^{2m} \\
&amp;=&amp; \alpha^2\frac{1- (1-\alpha)^{2k}}{1 - (1-\alpha)^2} - \frac{2\alpha}{k} \frac{1 - (1 - \alpha)^k}{1 - (1 - \alpha)} + \frac{1}{k} + \frac{\alpha^2(1-\alpha)^{2k}}{1 - (1 - \alpha)^2}
\end{array}
$$

Simplifying it according to Mathematica yields:

$$ J(\alpha) = \frac{\alpha}{2 - \alpha} + \frac{2 {(1 - \alpha)}^{k} -1}{k} $$

Using the following code on MATLAB yields something equivalent though different:

syms a k;

expr1 = (a ^ 2) * ((1 - ((1 - a) ^ (2 * k))) / (1 - ((1 - a) ^ 2)));
expr2 = ((2 * a) / k) * ((1 - ((1 - a) ^ (k))) / (1 - (1 - a)));
expr3 = (1 / k);
expr4 = ((a ^ 2) * ((1 - a) ^ (2 * k))) / (1 - ((1 - a) ^ (2)));

simpExpr = simplify(expr1 - expr2 + expr3 + expr4);


$$ J(\alpha) = \frac{-2}{\alpha - 2} - \frac{k - 2{(1 - \alpha)}^{k} + 1}{k} $$

Anyhow, those functions do have minimum.



So let's assume that we really only care about the approximation over the support (length) of the FIR filter. In that case, the optimization problem is just:
$$
J_2(\alpha) = \sum_{m=0}^{k-1} (\alpha(1-\alpha)^m - \frac{1}{k})^2
$$

Plotting $J_2(\alpha)$ for various values of $K$ versus $\alpha$ results in the date in the plots and table below.


  For $K$ = 8.     $\alpha_{\tt min}$ = 0.1533333
     For $K$ = 16.    $\alpha_{\tt min}$ = 0.08
     For $K$ = 24.    $\alpha_{\tt min}$ = 0.0533333
     For $K$ = 32.    $\alpha_{\tt min}$ = 0.04
     For $K$ = 40.    $\alpha_{\tt min}$ = 0.0333333
     For $K$ = 48.    $\alpha_{\tt min}$ = 0.0266667
     For $K$ = 56.    $\alpha_{\tt min}$ = 0.0233333
     For $K$ = 64.    $\alpha_{\tt min}$ = 0.02
     For $K$ = 72.    $\alpha_{\tt min}$ = 0.0166667   




The red dashed lines are $1/K$ and the green lines are $\alpha_{\tt min}$, the value of $\alpha$ that minimizes $J_2(\alpha)$ (chosen from $\tt alpha = [0:.01:1]/3;$).