When studying the "seasonal components" part of time series, I once read the following statement. I do not understand what role does the ergodic theorem play here?
The decomposition of the process is thus $$Y_t = X_t + Z_t + S_t \tag{25.37}$$ where $X_t$ handles the stationary fluctuations, $Z_t$ the long-term trends, and $S_t$ the repeating seasonal component.
If $Z_t = 0$, or equivalently if we have a good estimate of it and can subtract it out, we can find $S_t$ by averaging over multiple cycles of the seasonal trend. Suppose that we know the period of the cycle is $T$, and we can observe $m = n/T$ full cycles. Then $$S_t \approx \frac{1}{m} \sum_{j=0}^{m-1} Y_{t+jT} \tag{25.38}$$ This works because, with $Z_t$ out of the picture, $Y_t = X_t + S_t$, and $S_t$ is periodic, $S_t = S_{t+T}$. Averaging over multiple cycles, the stationary fluctuations tend to cancel out (by the ergodic theorem), but the seasonal component does not.
(Emphasis mine)
It looks like they're assuming that $E[X_t]=0$. But what that means is that $\int_\Omega X_t(\omega) \mathrm{d}P = 0$. What they would like to be able to say is that $\int_0^\infty X_t \mathrm{d}t = 0$. This is exactly what ergodicity tells you is true, that time averages of a single realization and averages over the space of realizations are equal. By the way a lot of the time in practice this is just assumed to be true for whatever system people are looking at. It was a big deal a few years back when Jonathan Mattingly from Duke was able to actually prove that the stochastically forced 2D Navier Stokes is ergodic for example.