# How to generate random samples of Gaussian distribution directly in the frequency domain?

One can easily draw (pseudo-)random samples from a normal (Gaussian) distribution by using, say, NumPy:

import numpy as np
mu, sigma = 0, 0.1 # mean and standard deviation
s = np.random.normal(mu, sigma, 1000)


Now, consider the Fast Fourier transform of s:

from scipy.fftpack import fft
sHat = fft(s)


Can we generate sHat directly without the Fourier-transform of s?

I have recently tried to discuss a practical implementation of such thought herein.

You can, but... you'll need to keep symmetry if your original time-domain signal is real-valued.

If a signal $x$ is real-valued, then its DFT $X$ will exhibit complex-conjugate symmetry: $$X[k] = X^*[N-k].$$

So you can generate $N$ Gaussian pseudo-random noise samples, $g[n]$, and place them in the frequency domain noise vector, $\epsilon$ as: $$\epsilon[k] = g[k] + j g[k+N/2]$$ for $k \in \{ 0, 1, \ldots, N/2-1\}$ and $$\epsilon[k] = \epsilon^*[N-k]$$ for $k \in \{ N/2, N/2+1, \ldots, N-1 \}$ where $\epsilon^*$ is the complex conjugate of $\epsilon$ and is equal to $\Re[{\epsilon}] - \Im[{\epsilon}]$ (i.e. the same real part and the negative of the imaginary part).

• Peter: As you probably know, I'm a beginner. When you have a chance, could you explain why that's necessary and what $\epsilon^{*}$ is. Thanks. Feb 6, 2018 at 16:58
• @markleeds added some details. Let me know if more is needed.
– Peter K.
Feb 6, 2018 at 20:11
• Peter: I'll have to look at the detailed version carefully. If I don't get back to you, I either understand it or I'm too lost it to even have a question. thanks. Feb 7, 2018 at 5:41
• @ Peter K: I think I get it. Since the DFT ( and the FFT ) uses the complex exponential, the summation assumes complex conjugate symmetry of the observations . Is there a FFT algorithm that uses the trigonometric representation so that the conjugate symmetry issue does not arise ? Thanks. Feb 8, 2018 at 2:49
• @markleeds There exist real-only FFT algorithms. But if the signal is real-valued, the complex conjugate symmetry will always arise.
– Peter K.
Feb 8, 2018 at 12:16