Given some data x
:
from pandas_datareader.data import DataReader as dr
x = np.squeeze(dr(\'DTWEXB\', \'fred\').dropna().values)
I
Take the z-transform of your filter, that gives you the values for the numerator b
and denominator a
:
alpha
y(z) = ------------------ x(z)
1 - (1-alpha) z^-1
So you run
import scipy.signal
x[0] /= alpha
y = scipy.signal.lfilter([alpha], [1, - 1 + alpha], x)
Which yields
array([ 101.1818 , 101.176862 , 101.16819314, ..., 120.9813121 ,
120.92484874, 120.85786628])
Note I have scaled x[0]
to account for the initial condition you wanted.