Tuesday, October 31, 2017

noise - 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)

Considering "the Fourier transform of white noise is white noise":


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




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




Answer



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).


No comments:

Post a Comment

digital communications - Understanding the Matched Filter

I have a question about matched filtering. Does the matched filter maximise the SNR at the moment of decision only? As far as I understand, ...