In [1, p. 62 exercise 3.19] we are asked to find for the multiple sinusoidal process
x[n]=\sum\limits_{i=1}^{P}A_{i}\cos(2\pi f_{i}n+\phi_{i})

the ensemble ACF and the temporal ACF as M\rightarrow \infty , where the \phi_{i}‘s are all uniformly distributed random variables on [0, 2 \pi) and independent of each other. We are also asked to determine if this random process is autocorrelation ergodic.
Solution: We note that the joint p.d.f of the uniformly random variables \phi_{i} is given by f(\boldsymbol{\phi})=\prod_{i=1}^{P}f(\phi_{i})=\frac{1}{(2\pi)^{P}}, with domain \mathbb{D}= \mathbb{A}^{P}, \; \mathbb{A} =[0, 2 \pi) we can proceed to calculate the ensemble autocorrelation function which is defined as:
r_{xx}[k]=E \left\{ x^{\star}[n] x[n+k] \right\}
=\int\limits_{\mathbb{D}}\sum\limits_{i=1}^{P}A_{i}\cos(2\pi f_{i}n+\phi_{i})\sum\limits_{\ell=1}^{P}A_{\ell}\cos(2\pi f_{\ell}(n+k)+\phi_{\ell}) f(\boldsymbol{\phi})d\boldsymbol{\phi}
=\sum\limits_{i=1}^{P}\sum\limits_{\ell=1, \ell\neq i}^{P} \int_{0}^{2\pi} \int_{0}^{2\pi}\frac{A_{i}A_{\ell}}{(2\pi)^{2}}\cos(2\pi f_{i}n+\phi_{i})\cos(2\pi f_{\ell}(n+k)+\phi_{\ell}) d\phi_{i}d\phi_{\ell}
 + \sum\limits_{i=1}^{P}\int_{0}^{2\pi} \frac{A_{i}^{2}}{(2\pi)}\cos(2\pi f_{i}n+\phi_{i})\cos(2\pi f_{i}(n+k)+\phi_{i})d\phi_{i}
=\sum\limits_{i=1}^{P} \sum\limits_{\ell=1, \ell\neq i}^{P} \int_{0}^{2\pi} \frac{A_{i}A_{\ell}}{(2\pi)^{2}} \underbrace{\left[ \sin(2\pi f_{i}n+\phi_{i})\right]_{0}^{2\pi}}_{=0}\cos(2\pi f_{\ell}(n+k)+\phi_{\ell}) d\phi_{\ell}
 + \sum\limits_{i=1}^{P}\int_{0}^{2\pi} \frac{A_{i}^{2}}{(2\pi)}\cos(2\pi f_{i}n+\phi_{i})\cos(2\pi f_{i}(n+k)+\phi_{i})d\phi_{i}
=\sum\limits_{i=1}^{P}\int_{0}^{2\pi} \frac{A_{i}^{2}}{(2\pi)}\cos(2\pi f_{i}n+\phi_{i})\cos(2\pi f_{i}(n+k)+\phi_{i})d\phi_{i}

As in exercise [2] we can use the trigonometric relation [3, p. 810] :
2\cos\frak{A}\cos\frak{B} = \cos(\frak{A-B}) + \cos(\frak{A+B}) (1)

(\frak{A}=2\pi f_{i}(n+k)+\phi_{i}, \frak{B}=2\pi f_{i}n+\phi_{i}) to further simplify the expression for the ensemble autocorrelation function:
r_{xx}[k]=\sum\limits_{i=1}^{P}\int_{0}^{2\pi} \frac{A_{i}^{2}}{(4\pi)}\cos(2\pi f_{i}k)d\phi_{i}
 +\sum\limits_{i=1}^{P}\int_{0}^{2\pi}\frac{A_{i}^{2}}{(4\pi)}\cos(2\pi f_{i}(2n+k)+2 \phi_{i})d\phi_{i}
=\sum\limits_{i=1}^{P}\int_{0}^{2\pi} \frac{A_{i}^{2}}{(4\pi)}\cos(2\pi f_{i}k)d\phi_{i}
 +\sum\limits_{i=1}^{P} \frac{A_{i}^{2}}{(8\pi)}\underbrace{\left[\sin(2\pi f_{i}(2n+k)+2 \phi_{i})\right]_{\phi_{i}=0}^{2\pi}}_{=0}
=\sum\limits_{i=1}^{P} \frac{A_{i}^{2}}{2}\cos(2\pi f_{i}k) (2)

Having obtained the ensemble autocorrelation function we can proceed to obtain the temporal autocorrelation function, which we hope will be a good approximation \hat{r}_{xx}[k] to the ensemble autocorrelation function r_{xx}[k]. By definition the temporal autocorrelation function is given by
\hat{r}_{xx}[k]=\frac{1}{2M+1} \sum\limits_{n=-M}^{M} x[n+k]x^{\star}[n]
=\frac{1}{2M+1} \sum\limits_{n=-M}^{M}\Bigg[ \left(\sum\limits_{i=1}^{P}A_{i}\cos(2\pi f_{i}(n+k)+\phi_{i})\right) \cdot
 \cdot \left(\sum\limits_{\ell=1}^{P}A_{\ell}\cos(2\pi f_{\ell}n+\phi_{\ell}) \right)\Bigg]
=\sum\limits_{i=1}^{P}\sum\limits_{\ell=1,\ell \neq i}^{P}\sum\limits_{n=-M}^{M} \frac{A_{i}A_{\ell}}{2M+1} \cos(2\pi f_{i}(n+k)+\phi_{i})
\cos(2\pi f_{\ell}n+\phi_{\ell})
 + \sum\limits_{i=1}^{P}\sum\limits_{n=-M}^{M}\frac{A_{i}^{2}}{2M+1}\cos(2\pi f_{i}(n+k)+\phi_{i})
\cos(2\pi f_{i}n+\phi_{i}) (3)

The second sum of the previous relation can be simplified by one of the derived formulas of [2], for e^{j2\pi f_{0}}\neq 1 :
\frac{1}{2M+1}\sum\limits_{n=-M}^{M}A^{2}\cos(2\pi f_{0}n+\phi)\cos(2\pi f_{0}(n+k)+\phi) =
\frac{A^{2}}{2} \cos(2\pi f_{0}k) + \frac{A^{2}}{2(2M+1)}\cos(2\pi f_{0}k+2\phi)\frac{\sin(2 \pi f_{0}(2M+1))}{\sin(2\pi f_{0})}

Thus the temporal autocorrelation function may be expressed, as long as e^{j2\pi f_{i}}\neq 1, \; i=1,...,P as:
\hat{r}_{xx}[k]=\sum\limits_{i=1}^{P}\sum\limits_{\ell=1,\ell \neq i}^{P}\sum\limits_{n=-M}^{M} \frac{A_{i}A_{\ell}}{2M+1} \cos(2\pi f_{i}(n+k)+\phi_{i})
\cos(2\pi f_{\ell}n+\phi_{\ell})
 + \sum\limits_{i=1}^{P} \frac{A_{i}^{2}}{2} \cos(2\pi f_{i}k)
 +\sum\limits_{i=1}^{P} \frac{A_{i}^{2}}{2(2M+1)}\cos(2\pi f_{i}k+2\phi_{i})\frac{\sin(2 \pi f_{i}(2M+1))}{\sin(2\pi f_{i})} (4)

In order to simplify the relation further, especially the first sum, we will again use (1), with \frak{A} =2\pi f_{i}(n+k)+\phi_{i} and \frak{B} = 2\pi f_{\ell}n+\phi_{\ell}, and thus :
 \sum\limits_{n=-M}^{M}\frac{A_{i}A_{\ell}}{2M+1} \cos(2\pi f_{i}(n+k)+\phi_{i})
\cos(2\pi f_{\ell}n+\phi_{\ell}) =
 \sum\limits_{n=-M}^{M}\frac{A_{i}A_{\ell}}{2M+1} \cos(2 \pi (f_{i}-f_{\ell})n+2\pi f_{i}k+\phi_{i}-\phi_{\ell}) +
 \sum\limits_{n=-M}^{M}\frac{A_{i}A_{\ell}}{2M+1} \cos(2 \pi (f_{i} + f_{\ell})n+2\pi f_{i}k+\phi_{i}+\phi_{\ell}) (5)

We see that both distinct parts are of the form \sum_{n=-M}^{M}\cos(2\pi \frak{f}_{1} n+ 2\pi \frak{f}_{2} k + \Phi), and thus it remains to simplify this relation. Again using a trigonometric formula [3, p. 810]:
\cos(\frak{A+B})=\cos\frak{A}\cos\frak{B}-\sin\frak{A}\sin\frak{B} (6)

with \frak{A}= 2\pi \frak{f}_{1} n and \frak{B}=2\pi \frak{f}_{2} k + \Phi we can simplify the relation as:
\sum\limits_{n=-M}^{M}\cos(2\pi \frak{f}_{1} n+ 2\pi \frak{f}_{2} k + \Phi)
=\cos(2\pi \frak{f}_{2} k + \Phi)\sum\limits_{n=-M}^{M}\cos(2\pi \frak{f}_{1} n)
 -\sin(2\pi \frak{f}_{2} k + \Phi)\underbrace{\sum\limits_{n=-M}^{M}\sin(2\pi \frak{f}_{1} n)}_{=0, \textrm{ \scriptsize{odd symmetry of sine}}}
=\cos(2\pi \frak{f}_{2} k + \Phi)\sum\limits_{n=-M}^{M}\cos(2\pi \frak{f}_{1} n)

Furthermore it was shown in [2] that \sum_{n=-M}^{M}\cos(2\pi (2 f_{0}))=\frac{\sin(\pi (2 f_{0})(2M+1))}{\sin(\pi(2f_{0})} , for e^{j2\pi 2f_{0}}\neq 1, so we can further simplify the previous relation by:
\sum\limits_{n=-M}^{M}\cos(2\pi \frak{f}_{1} n+ 2\pi \frak{f}_{2} k + \Phi)=\cos(2\pi \frak{f}_{2} k + \Phi)\sum\limits_{n=-M}^{M}\cos(2\pi \frak{f}_{1} n)
= \cos(2\pi \frak{f}_{2} k + \Phi)\frac{\sin(\pi \frak{f}_{1}(2M+1))}{\sin(\pi\frak{f}_{1})}, \; e^{j2\pi\frak{f}_{1}}\neq 1 (7)

Thus finally we can simplify (5) by:
 \sum\limits_{n=-M}^{M}\frac{A_{i}A_{\ell}}{2M+1} \cos(2\pi f_{i}(n+k)+\phi_{i})
\cos(2\pi f_{\ell}n+\phi_{\ell}) =
 \frac{A_{i}A_{\ell}}{2M+1} \cos(2\pi f_{i}k+\phi_{i}-\phi_{\ell}) \frac{\sin(\pi (f_{i}-f_{\ell})(2M+1))}{\sin(\pi (f_{i}-f_{\ell}))} +
 \frac{A_{i}A_{\ell}}{2M+1} \cos(2\pi f_{i}k+\phi_{i}+\phi_{\ell}) \frac{\sin(\pi (f_{i}+f_{\ell})(2M+1))}{\sin(\pi (f_{i}+f_{\ell}))} (8)

So finally the temporal autocorrelation (4) can be reduced using (8) to the following formula:
\hat{r}_{xx}[k]=\sum\limits_{i=1}^{P}\sum\limits_{\ell=1,\ell \neq i}^{P}\frac{A_{i}A_{\ell}}{2M+1} \cos(2\pi f_{i}k+\phi_{i}-\phi_{\ell}) \frac{\sin(\pi (f_{i}-f_{\ell})(2M+1))}{\sin(\pi (f_{i}-f_{\ell}))}
 +\sum\limits_{i=1}^{P}\sum\limits_{\ell=1,\ell \neq i}^{P}\frac{A_{i}A_{\ell}}{2M+1} \cos(2\pi f_{i}k+\phi_{i}+\phi_{\ell}) \frac{\sin(\pi (f_{i}+f_{\ell})(2M+1))}{\sin(\pi (f_{i}+f_{\ell}))}
 + \sum\limits_{i=1}^{P} \frac{A_{i}^{2}}{2} \cos(2\pi f_{i}k)
 +\sum\limits_{i=1}^{P} \frac{A_{i}^{2}}{2(2M+1)}\cos(2\pi f_{i}k+2\phi_{i})\frac{\sin(2 \pi f_{i}(2M+1))}{\sin(2\pi f_{i})} (9)

Rearranging the terms on the right we see that the temporal autocorrelation function equals the ensemble autocorrelation function with an additional error \epsilon, which we have derived for the the case when e^{(j2\pi f_{i})}\neq 1 \; , i=1,...,P :
\hat{r}_{xx}[k]=\sum\limits_{i=1}^{P} \frac{A_{i}^{2}}{2} \cos(2\pi f_{i}k)
 \sum\limits_{i=1}^{P}\sum\limits_{\ell=1,\ell \neq i}^{P}\frac{A_{i}A_{\ell}}{2M+1} \cos(2\pi f_{i}k+\phi_{i}-\phi_{\ell}) \frac{\sin(\pi (f_{i}-f_{\ell})(2M+1))}{\sin(\pi (f_{i}-f_{\ell}))}
 +\sum\limits_{i=1}^{P}\sum\limits_{\ell=1,\ell \neq i}^{P}\frac{A_{i}A_{\ell}}{2M+1} \cos(2\pi f_{i}k+\phi_{i}+\phi_{\ell}) \frac{\sin(\pi (f_{i}+f_{\ell})(2M+1))}{\sin(\pi (f_{i}+f_{\ell}))}
 +\sum\limits_{i=1}^{P} \frac{A_{i}^{2}}{2(2M+1)}\cos(2\pi f_{i}k+2\phi_{i})\frac{\sin(2 \pi f_{i}(2M+1))}{\sin(2\pi f_{i})}
=r_{xx}[k] +\epsilon

At once we see again that when M\rightarrow \infty that the error goes to zero \epsilon \rightarrow 0. Thus the random process of the sum of sinusoids is also autocorrelation ergodic as long as e^{(j2\pi f_{i})}\neq1 \; , i=1,...,P . It is also easy to recognize, by using the argumentation of the previous exercise [2] , that this is not true if e^{(j2\pi f_{i})}\neq1 \; , i=1,...,P does not hold. In this case parts of the the error of equation (3) are proportional to M as was already observed in [2] . QED.

[1] Steven M. Kay: “Modern Spectral Estimation – Theory and Applications”, Prentice Hall, ISBN: 0-13-598582-X.
[2] Chatzichrisafis: “Solution of exercise 3.18 from Kay’s Modern Spectral Estimation - Theory and Applications”.
[3] Granino A. Korn and Theresa M. Korn: “Mathematical Handbook for Scientists and Engineers”, Dover, ISBN: 978-0-486-41147-7.