I'm a bit confused with the definition of the power spectral density (PSD). From Wiki https://en.wikipedia.org/wiki/Spectral_density , I found the definition is:
$$ S_{xx}(\omega) = \lim_{T\rightarrow \infty}\mathbb{E}[|x(\omega)|^2], $$ where $x(\omega)$ is the Fourier transform of the process $x(t)$.
I'm really confuses with that expectation $\mathbb{E}$ in the above equation. The expectation is taken w.r.t. $x(t)$, but $|x(\omega)|^2$ is a function of angular $\omega$. There is no $x(t)$ in the integrand at all, thus $$ \mathbb{E}[|x(\omega)|^2] = |x(\omega)|^2. $$ What is the point of this expectation?
However, in the other hand, $$ \mathbb{E} \left[ \left | x(\omega) \right |^2 \right] = \mathbb{E} \left[ \frac{1}{T} \int_0^T x^*(t) e^{i\omega t}\, dt \int_0^T x(t') e^{-i\omega t'}\, dt' \right] = \frac{1}{T} \int_0^T \int_0^T \mathbb{E}\left[x^*(t) x(t')\right] e^{i\omega (t-t')}\, dt\, dt' \neq |x(\omega)|^2 $$ the PSD is the Fourier transform of the cross-covariance (auto-correlation) of the process. This exectation is indeed needed.
Where am I wrong? Can't those integrals switch orders?