Monday, March 6, 2017

fft - What is the phase and magnitude response of white noise?


I would like to create white noise in the frequency domain, and then transform it to the time domain using python. To understand the problem, I simply generated white noise in the time domain, and transformed it to freq domain:


import scipy.signal as sg
import numpy as np
import matplotlib.pyplot as plt


e = np.random.normal(0,1,1e3)
E = sg.fft(e)

plt.figure("Bode plot")
plt.subplot(211)
plt.title("Magitude")
plt.plot(abs(E))
plt.subplot(212)
plt.title("Phase")
plt.plot(np.angle(E))

plt.show()

I does not look at all as I expected: Bode plot of white noise Questions:



  • Isn't white noise supposed to have a flat magnitude response? (equal amounts for all frequencies)

  • What is the relationship between the standard deviation (1 in my example) and the magnitude and phase?


Thank you in advance!



Answer





Isn't white noise supposed to have a flat magnitude response? (equal amounts for all frequencies)



The expected magnitude response of white noise is flat (this is what JasonR calls the power spectral density). Any particular instance of a white noise sequence will not have precisely flat response (this is what JasonR's comment refers to as the power spectrum).


In fact, the Fourier transform of white noise is... white noise!



What is the relationship between the standard deviation (1 in my example) and the magnitude and phase?



There will be no relationship between the standard deviation and the phase. As for the magnitude, suppose $n(t)$ is stationary white noise with zero mean and standard deviation $\sigma$. Then the autocorrelation (covariance) is:


$$ R_{nn}(\tau) = E[n(t)n(t+\tau)] = \sigma^2\delta(\tau) $$


So the power spectral density is just $\sigma^2$ (though for discrete-time, there will be a scaling based on the duration of the signal).





Questions from comment:




  1. When you say that the Fourier transform is also white noise, how can I measure the std-dev when the transform is complex? Real, imaginary part or some combination?



Assume that our noise is discrete-time and is $n[m]$ (zero mean, Gaussian, white noise with variance $\sigma^2$). Then the transform is:


$$ \begin{eqnarray} N[k] &=& \sum_{m=0}^{M-1} n[m] e^{-j2\pi mk/M} \\ &=& \sum_{m=0}^{M-1} n[m] \cos(2\pi mk/M) + j n[m] \sin(2\pi mk/M) \end{eqnarray} $$


and the expected value is:



$$ \begin{eqnarray} E\left[N[k]\right] &=& E\left[\sum_{m=0}^{M-1} n[m] e^{-j2\pi mk/M} \right]\\ &=& \sum_{m=0}^{M-1} E\left[n[m]\right] e^{-j2\pi mk/M} \\ &=& 0 \end{eqnarray} $$


The variance of the real part is given by:


$$ \begin{eqnarray} E\left[ (\Re N[k])^2 \right] &=& E \left [ \sum_{m=0}^{M-1} n[m] \cos(2\pi mk/M) \cdot \sum_{p=0}^{M-1} n[p] \cos(2\pi pk/M) \right ]\\ &=& E\left[ \sum_{m=0}^{M-1} \sum_{p=0}^{M-1} n[m]n[p] \delta[n-p] \cos(2\pi mk/M)\cos(2\pi pk/M) \right]\\ &=& \sum_{m=0}^{M-1} E\left[ n[m]^2 \right]\cos^2(2\pi mk/M)\\ &=& \sigma^2\sum_{m=0}^{M-1} \cos^2(2\pi mk/M)\\ &=& \sigma^2 \left( \frac{M}{2} + \frac{\cos(M+1) 2\pi k/M \sin(2\pi Mk/M) }{ 2 \sin (2\pi k/M) } \ \ \ \right)\\ &=& \frac{\sigma^2 M}{2} \end{eqnarray} $$


I believe the imaginary part will behave the same way.




  1. Could you please enlighten me how the duration of the signal relates to the power spectral density (for discrete time situations)



I believe that (based on the above derivation), the power spectral density (the expected value of the square of the DFT) will scale linearly as the duration.





  1. If the phase is not affected by the std-dev, what determines the 3 degree amplitude, and the type of distribution (seems to be uniform rather than normal)



Check out the table on page 2 of this PDF file. it says that the argument (phase) of the coefficients will be uniformly distributed, as you state. Screenshot of the table included below.


enter image description here


No comments:

Post a Comment

periodic trends - Comparing radii in lithium, beryllium, magnesium, aluminium and sodium ions

Apparently the of last four, $\ce{Mg^2+}$ is closest in radius to $\ce{Li+}$. Is this true, and if so, why would a whole larger shell ($\ce{...