title: Methods for quickly calculating standard deviation of large number set in Numpy
body: <p>What's the best(fastest) way to do this?</p>
  
  <p><img src="https://i.stack.imgur.com/2ZvDZ.png" alt="question"></p>
  
  <p>This generates what I believe is the correct answer, but obviously at N = 10e6 it is painfully slow. I think I need to keep the Xi values so I can correctly calculate the standard deviation, but are there any techniques to make this run faster?</p>
  
  <pre><code>def randomInterval(a,b):
      r = ((b-a)*float(random.random(1)) + a)
      return r 
  
  N = 10e6
  Sum = 0
  x = []
  for sample in range(0,int(N)):
      n = randomInterval(-5.,5.)
      while n == 5.0:
          n = randomInterval(-5.,5.) # since X is [-5,5)
      Sum += n
      x = np.append(x, n)
  
  A = Sum/N
  
  for sample in range(0,int(N)):
      summation = (x[sample] - A)**2.0
  
  standard_deviation = np.sqrt((1./N)*summation)
  </code></pre>