Solution (source code)

= Solution

Use the one-sided convention: integrating the <one-sided spectral density> over $[0,\pi]$ gives the <variance>. A standard sufficient hypothesis is absolute summability of the <autocovariance sequence>:
$$
\boxed{\gamma_0+2\sum_{k=1}^{\infty}|\gamma_k|<\infty.}
$$
For a real <weakly stationary process>, extend the sequence by $\gamma_{-k}=\gamma_k$. The Fourier pair is
$$
\boxed{f_X(\omega)=\frac1\pi\sum_{k\in\mathbb Z}\gamma_ke^{ik\omega}
=\frac1\pi\left(\gamma_0+2\sum_{k\ge1}\gamma_k\cos(k\omega)\right),\qquad
\gamma_k=\int_0^\pi f_X(\omega)\cos(k\omega)\,d\omega.}
$$
Absolute summability makes the series uniformly convergent and continuous; cosine orthogonality gives the inverse relation. Nonnegativity follows from the <spectral measure of a stationary time series>, or from the nonnegative Fejér approximations obtained by taking <variances> of finite Fourier sums.

For precision, absolute summability is sufficient, not necessary. The exact general condition is that the spectral measure be <absolutely continuous with respect to> <Lebesgue measure>. For example, a density constant on $[0,\pi/2]$ and zero elsewhere has $\gamma_k$ proportional to $\sin(k\pi/2)/k$, which is not absolutely summable. Thus the displayed absolutely convergent Fourier formula answers the usual covariance-summability version; an arbitrary density need only have the integral inverse relation and Fejér-mean Fourier recovery in $L^1$.