The expectation in power spectral density 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?
I think a better definition of the power spectrum is the following:


  The power spectrum of $x(t)$ is the Fourier transform of the autocorrelation function of $x(t)$, where $x(t)$ can be either a deterministic power signal, or a wide-sense stationary (WSS) random process. The definition of the autocorrelation function depends on the model for $x(t)$.


If $x(t)$ is modeled as a WSS random process, then the autocorrelation function is defined by

$$R_x(\tau)=E\big\{x^*(t)x(t+\tau)\big\}\tag{1}$$

For deterministic power signals, the autocorrelation function is given by

$$R_x(\tau)=\lim_{T\to\infty}\frac{1}{T}\int_{-T/2}^{T/2}x^*(t)x(t+\tau)dt\tag{2}$$

In this answer it is shown that the following definition of the power spectrum for a WSS random process $x(t)$

$$S_x(\omega)=\lim_{T\rightarrow\infty}E\left\{ \frac{1}{T}\left| \int_{-T/2}^{T/2}x(t)e^{-j\omega t}dt \right|^2 \right\}\tag{3}$$

is equivalent to the definition of the power spectrum as the Fourier transform of $(1)$.

For deterministic power signals, the corresponding definition of the power spectrum is

$$S_x(\omega)=\lim_{T\rightarrow\infty}\frac{1}{T}\left| \int_{-T/2}^{T/2}x(t)e^{-j\omega t}dt \right|^2 \tag{4}$$

which can also be shown to be equivalent to the Fourier transform of $(2)$.

The definitions of autocorrelation and power spectrum of deterministic power signals is described in Chapter 12 of

Papoulis, A., The Fourier Integral and its Applications, McGraw Hill, 1962.

A good reference on random processes and the corresponding definitions of autocorrelation and power spectra is

Papoulis, A. and S.U. Pillai, Probability, random
variables, and stochastic processes, Boston: McGraw-Hill, 2002.