title: Is there a faster wasy to create an exponential moving average than for loop?
body: <p>Is there a faster way to create an exponential moving average than for loop?</p>
  <p>I am priming the first n values of exp_aves to be mean of first n obseravtions.</p>
  <pre><code>def exp_mov_ave(observations, n):
  
      exp_ave = np.mean(observations[0:n])    
      
      lambdak = (n - 1) / (n + 1)
      exp_aves = []
  
      for i,element in enumerate(observations):
          if (i &gt;= n):
              exp_ave = (lambdak * exp_ave) + ((1 - lambdak) * element)
  
          exp_aves.append(exp_ave)
  
      return np.array(exp_aves)
  </code></pre>