Optimising Probabilistic Weighted Moving Average (PEWMA) df.iterrows loop in Pandas
I think you can use just raw numpy arrays for speeding it up:

after #the PEWMA Model you can just use following code:

_x = df[value_col]
_mean, _std, _var = np.zeros(_x.shape), np.zeros(_x.shape), np.zeros(_x.shape)

for i in range(1, len(_x)):
    diff = _x[i] - _mean[i-1]

    p = norm.pdf(diff / _std[i-1]) if _std[i-1] != 0 else 0 # Prob of observing diff
    a_t = a * (1 - beta * p) if (i-1) &gt; T else 1 - 1/i # weight to give to this point
    incr = (1 - a_t) * diff

    # Update Mean, Var, Std
    v = a_t * (_var[i-1] + diff * incr)
    _mean[i] = _mean[i-1] + incr
    _var[i] = v
    _std[i] = np.sqrt(v)

pewm = pd.DataFrame({'Mean': _mean, 'Var': _var, 'Std': _std}, index=df.index)


If you need to apply it to really big data you could make it even faster by using numba package:

from numba import njit

# numba has some issues with stats's norm.pdf so redefine it here as function
@njit
def norm_pdf(x):
    return np.exp(-x**2/2)/np.sqrt(2*np.pi)

@njit
def pwma(_x, a, beta, T):
    _mean, _std, _var = np.zeros(_x.shape), np.zeros(_x.shape), np.zeros(_x.shape)
    _mean[0] = _x[0]

    for i in range(1, len(_x)):
        diff = _x[i] - _mean[i-1]

        p = norm_pdf(diff / _std[i-1]) if _std[i-1] != 0 else 0 # Prob of observing diff
        a_t = a * (1 - beta * p) if (i-1) &gt; T else 1 - 1/(i) # weight to give to this point
        incr = (1 - a_t) * diff

        # Update Mean, Var, Std
        v = a_t * (_var[i-1] + diff * incr)
        _mean[i] = _mean[i-1] + incr
        _var[i] = v
        _std[i] = np.sqrt(v)
    return _mean, _var, _std

# Using :
_mean, _var, _std = pwma(df[value_col].values, 0.99, 0.5, 30)
pewm = pd.DataFrame({'Mean': _mean, 'Var': _var, 'Std': _std}, index=df.index)