# Generate time-domain random signal from PSD

Given an analytical description of the PSD, for example (MATLAB "pseudocode"):

N = 20400;
bw = 2 * 2040 / N; % double-sided spectrum, 20% occupied
PSD = zeros(N,1);
P0 = sigma * sqrt(N/bw); % sigma^2 = (P0^2/N) * bw
PSD(1:2040) = P0;
PSD(18362:end) = P0;


what is the "correct" way to generate a time-domain signal $x[n]$ which is a realization of this PSD, i.e. which has variance of $\sigma^2$ and a DFT where all bins $2041, \dots, 18361$ are zero?

I found this: http://www.mathworks.com/matlabcentral/newsreader/view_thread/264846. However, I am confused since there only the phase is taken randomly but not the magnitude which would result in a perfect "brick-wall" spectrum when taking the DFT of each realization (because the magnitude and magnitude-squared is not random). However, this is only the case if the number of samples approaches infinity.

Important: I do not want to generate iid. white Gaussian samples and filter them - I would like to generate the random signal in DFT domain and then use the inverse DFT to generate the time domain signal.

• Why wouldn't you want to filter white noise to shape its PSD the way you want it? That's the only way to go. – Matt L. Apr 7 '15 at 6:51
• Loos like you have a PSD for band-stop filter. As Matt L said you can try i.i.d. filtering approach to find the time domain process. Take the IDFT of PSD to get sample auto-correlation function. Plug that in to a Yule-walker equation for AR or ARMA to generate realization of random sequence you want. – Oliver Apr 7 '15 at 6:59
• The PSD is definitely not similar to a PDF. What do you mean? – Matt L. Apr 7 '15 at 7:55
• The power spectral density tells you nothing about the distribution of the random variables that you wish to generate; except indirectly it says that the random variables must have specific correlations as described by the inverse Fourier transform (autocorrelation function) of the power spectral density. For example, a sequence of iid Laplacian random variables (pdf $\frac 12 e^{-|x|}$) will have the same flat PSD as a sequence of iid zero-mean Gaussian variables with the same variance. Similarly if the target PSD is not flat; though it is more difficult to generate ...... – Dilip Sarwate Apr 7 '15 at 14:58
• @divB just want to confirm your suspicion about using constant magnitudes in the frequency domain; it's wrong and a very common mistake. – DanielSank Jun 15 '15 at 21:46