Autocorrelation function and correlation integral I am confused by the definition of autocorrelation function. It is originally defined as the expected value 
$$R_{XX}(\tau) = E[(X(t)X(t+\tau)] = \langle X(t)X(t+\tau)\rangle\tag{1}$$
where $\langle\cdot\rangle$ is the ensemble average, and suppose they are all real signals. However, I see another definition defined by the correlation integral (e.g., see Autocorrelation - Wiki), which reads
$$R_{XX}(\tau) = \int_{-\infty}^\infty X(t)X(t+\tau)dt \tag{2}$$
Under assumption of ergodicity, Eq.(1) can be approximated by temporal averaging, i.e., 
$$R_{XX}(\tau) = \lim_{T\to\infty}\frac{1}{2T}\int_{-T}^TX(t)X(t+\tau)dt\tag{3}$$
But I don't see how Eq.(3) turning into Eq.(2), or how Eq.(2) being equivalent to Eq.(1).

So am I misunderstanding or missing anything here, or the one defined by correlation integral is another version of "autocorrelation"?

Any hints would be helpful!

Thanks!

EDIT: Another question is, for Eq.(2), if one sets $\tau=0$, the result is expected to be the variance (or "energy") of the signal. However, if we start from Eq.(2),
$$R_{XX}(0) = \lim_{T\to\infty}\frac{1}{2T}\int_{-T}^T X^2(t)dt$$
For any signal in $\mathcal{L}^2$ space (which has finite energy), the integral will be finite, but as $T\to\infty$, $R_{XX}(0)\to0$; that's not physical. Where did I go wrong?
The definition of auto-correlation depends on the type of signal. For random processes, the auto-correlation function is defined by the expectation given in Eq. $(1)$ of your question.

For deterministic signals, there are two definitions, depending on whether the signal is an energy signal (i.e., has finite energy), or a power signal (i.e., has finite power but infinite energy). In the first case, the auto-correlation is defined by Eq. $(2)$ in your question. In the latter case, the integral $(2)$ doesn't exist, and the auto-correlation is defined by the limit given in Eq. $(3)$.