title: Using Box-Muller Method to Generate Gaussian Random Numbers in Python
body: <p>Right now, I am using the Box-Muller method to generate 10 24 Gaussian random numbers in python. I am supposed to plot the power spectrum, and see a Gaussian curve. My code is below:    </p>
  
  <pre><code>import numpy as np
  import matplotlib.pyplot as plt
  def fast_fourier_transform(y):
      '''Return the fast Fourier transform of y.'''
      Y = np.fft.fft(y)
      f = np.fft.fftfreq(len(y),1.0/1024)
      return f,Y
  
      rlist=[]
  
      for i in range((2**10)/2):
          mu=0
          sigma=1
  
      u = np.random.random()
      v = np.random.random()
  
      z1 = np.sqrt(-2.0 * np.log(u)) * np.sin(2.0 * np.pi * v)
      z2 = np.sqrt(-2.0 * np.log(u)) * np.cos(2.0 * np.pi * v)
  
      x1 = mu + z1 * sigma
      x2 = mu + z2 * sigma
      rlist.append(x1)
      rlist.append(x2)
      print u, v, x1, x2
  f,Y=fast_fourier_transform(rlist)
  plt.plot(f,Y)
  
  plt.show()
  </code></pre>
  
  <p>However, when I plot this, I don't get a Gaussian distribution. My question is this: why am I not getting a Gaussian distribution in my Gaussian-generated white noise power spectrum? Am I plotting something wrong? Thank you in advance.</p>