Solved by KFrank in post #2 
              
              
                Hello Ahmed! 

As written, this doesn’t actually have a decay factor.  (Each value of 
y only has at most a single power of w.) 
I think you mean to write something like 
y[i] = w * y[i - 1] + x[i]


You can get what (I think) you want by pre-multiplying x with powers 
of the weight, and then using c…