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)