definations
$x(t)$ is a function of time. Physically, it can be voltage, displacement, magnetization and so on. It can be real, complex, vectors or more fancy numbers.
$C(t)$ is the auto correlation function of $x(t)$ , defined as:
$$ C(t)=\langle x(t) x^*(0) \rangle := \lim_{T\rightarrow \infty}\frac{1}{T}\int_0^T x(t'+t) x^*(t') dt' \tag{1} $$
$I(\omega)$ is the spectrum of $x(t)$, it is the Fourier transformation of $C(t)$, or it is the square of Fourier transformation of $x(t)$. These two definition are equivalent (apply convolution theorem): $$ I(\omega)= \int_{-\infty}^{+\infty} C(t) e^{-i\omega t} dt \tag{2} $$
$$ I(\omega)= \begin{vmatrix} \int_{-\infty}^{+\infty} x(t) e^{-i\omega t} dt \end{vmatrix}^2 \tag{3} $$
non-negativity of $I(\omega)$
We can show that, spectrum is non-negative: $$ I(\omega)= \begin{vmatrix} \int_{-\infty}^{+\infty} x(t) e^{-i\omega t} dt \end{vmatrix}^2 \geqslant 0 $$ And physically it makes sense, because $I(\omega)$ means the energy density within frequency range $[\omega , \omega+d\omega) $.
Energy density shouldn't be negative.
Question (1): what function $C(t)$ makes its Fourier transform $I(\omega)$ non-negative?
In practice, definition equation (2) is used rather than equation (3).
$C(t)$ is the inverse Fourier tranform of non-negative function $I(\omega)$.
I know some basic law like this: $$ \text{FT}[real,even]=real, even $$ $$ \text{FT}[real,odd]=imag, odd $$
I have no idea what should $C(t)$ be? $$ \text{FT}[???]=real, non \ negative $$ Understand the function class of $C(t)$ might help us solve Question (2), because later on, you will see, I'm doing a transformation to $C(t)$ (essentially it's a discretization), then perform Fourier transform. This discretization transformation might take $C(t)$ out of that class, therefore makes $I(\omega)$ no longer non-negative.
subtlety in numerics: $I(\omega)$ is no longer non-negative!
In numerical calculations, things become finite and discrete.
Equation (2) is modified to its numeric version:
$$ \int \xrightarrow{\text{numerics }} \sum $$ $$ \qquad \quad t \xrightarrow{\text{numerics }} t_i \quad i=0,1,2,\cdots,L $$
$$ \qquad \quad \omega \xrightarrow{\text{numerics }} \omega_n \quad n=0,1,2,\cdots,L $$ Or, an alternate way to understand numerics is to keep the continues integration, but sample the function $C(t)$ discretely and finitely: $$ C(t) \xrightarrow{numerics} C(t) \times \sum_{i=0}^{L-1} \delta(t-t_i) $$
Under this change, $I(\omega)$ is no longer non-negative.
I did some experiments, those negative value of $I(\omega)$ can be as large as 10% of the positive peak value of $I(\omega)$. Adding window function makes things better, but still have 0.1% negative spectrum density.
Only in some commensurate case, $I(\omega)$ is non-negative.
Question (2): is there any natural way to make $I(\omega)$ non-negative, in numerics?
I find adding absolute value might help $$I(\omega)\rightarrow |I(\omega)|$$ but don't see any reason, such as conservation of energy, so on
So, is there a natural way, to generate non-negative spectrum density, in numerics?