I have a power spectrum $S(\omega)$: a $1 \times N$ real vector that matches frequencies from 0 to 125Hz. I would like to create a time series $S(t)$ $[-\infty<t<\infty]$ that matches this spectrum. I used random phase, calculated IFFT, found the Fourier series coefficients ($a_0$,$A$,$B$) and presented the signal as:
$$S(t) = a_0 + \sum_{k=1}^{N/2}A_k\cos(2{\pi}f_skt/N)+B_k\sin(2{\pi}f_skt/N)$$
When I'm calculating $PSD\{S(t), 0<t<N\}$, I'm getting $S(\omega)$ exactly. However, when I'm calculating $PSD\{S(t), 0<t<M, N<M\},$ the spectrum becomes a pulse-train, multiplied by $M/N$ (as expected from the theory).
Is there a way to overcome this behavior and get exactly $S(\omega)$ for $N \lt M$?
Example behavior when $M=5N$: