title: pandas ewm var and std
body: <p>I unsuccessfully tried to replicate the calculation of exponential weighted moving variance.
  here is the code I used.</p>
  
  <pre><code>import pandas as pd
  import numpy as np
  
  
  l = [12., 12.5, 13.1, 14.6, 17.8, 19.1, 24.5]
  df = pd.DataFrame(data=l, columns=['data'])
  N = 5
  
  a = 2./(1+N)
  bias = (2-a)/2./(1-a)
  ewma = df.ewm(span=N).mean()
  var_pandas = df.ewm(span=N, adjust=False).var()
  
  var_calculated = (1-a) * (var_pandas.shift(1) + bias * a * (df - ewma.shift(1))**2)
  
  var_pandas
  Out[100]: 
          data
  0        NaN
  1   0.125000
  2   0.359231
  3   1.582143
  4   7.157121
  5  10.080647
  6  26.022245
  
  var_calculated
  Out[101]: 
          data
  0        NaN
  1        NaN
  2   0.261111
  3   1.264610
  4   6.246149
  5   9.135133
  6  24.123265
  </code></pre>
  
  <p>as you would see I still have a difference that I couldn't figure out.
  Grateful for your insights!</p>
  
  <p><em>I used the above formula from: <a href="https://stackoverflow.com/questions/40754262/pandas-ewm-std-calculation">pandas ewm.std calculation</a></em></p>