I am trying to check the calculations of ewm.std pandas so that I can implement a one-step update for my code. Here is a complete description of the problem with the code.
mrt = pd.Series(np.random.randn(1000))
N = 100
a = 2/(1+N)
bias = (2-a)/2/(1-a)
x = mrt.iloc[-2]
ma = mrt.ewm(span=N).mean().iloc[-3]
var = mrt.ewm(span=N).var().iloc[-3]
ans = mrt.ewm(span=N).std().iloc[-2]
print(np.sqrt( bias*(1-a) * (var + a * (x- ma)**2)), ans)
(1.1352524643949702, 1.1436193844674576)
I used the standard wording. Can someone tell me why these two values should not be the same? i.e. how pandas calculating exponentially weighted std?
EDIT: After Julien's answer - let me give you another use case. I am drawing a var relation computed in pandas, and using formula I derived from the Cython pandas ewm covariance code. This ratio should be 1. (I assume there is a problem with my formula if someone can point this out).
mrt = pd.Series(np.random.randn(1000))
N = 100
a = 2./(1+N)
bias = (2-a)/2./(1-a)
mewma = mrt.ewm(span=N).mean()
var_pandas = mrt.ewm(span=N).var()
var_calculated = bias * (1-a) * (var_pandas.shift(1) + a * (mrt-mewma.shift(1))**2)
(var_calculated/var_pandas).plot()
The plot clearly shows the problem.

EDIT 2: Judging by trial and error, I understood the correct formula:
var_calculated = (1-a) * (var_pandas.shift(1) + bias * a * (mrt-mewma.shift(1))**2)
, ! - ?