# Adjust decay rate dynamically

Say I have a stream of values $\langle s_1, s_2,\ldots\rangle$ coming in and a function

$$E_{s_1:s_n}(t) = E_{s_1:s_{n-1}}(t-1) + \alpha\cdot (s_t-E_{s_1:s_{n-1}}(t-1))$$

that compute their exponential moving average as the values flow in.

I would like the alpha, i.e the decay rate, to adjust dynamically as a function of the last $h$ values we have seen. That is, if the trend is that the values are similar then I want my rate to plateau.

Otherwise, if the trend is that the values are decreasing quickly, I would like the decay rate to be greater and vice-versa.

Right now, I was thinking of defining:

$$\alpha(s_{k-h}, s_{k-h-1}, \ldots , s_k) = E_{\Delta_{k-h}:\Delta_k}(t-1) + \alpha_\Delta \cdot ((s_k - s_{k-1}) - E_{\Delta_{k-h}:\Delta_k}(t-1))$$

That is, the exponential moving average of the difference between two consecutive values of our time serie with an arbitrary alpha ($\alpha_\Delta$)

I am not a statistician, just a student that tries to play with mathematics. Help is greatly welcomed, including links to resources that could help me solve this problem in a better fashion. I am completely open to new ideas!