Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save islands04/9ad557961acd9c3324c77af40dd18990 to your computer and use it in GitHub Desktop.
Save islands04/9ad557961acd9c3324c77af40dd18990 to your computer and use it in GitHub Desktop.
Basic example using mock data
import numpy as np
import padasip as pa
import matplotlib.pylab as plt
# prep data
N = 200 # the overall time series size
n = 5 # size of sample we want to feed into the filter
s = np.random.random(N) # generate the source input
d = np.zeros(N) # initialize the target array
for k in range((n-1), N):
d[k] = 2*s[k] + 0.9*s[k-1] - 2*s[k-2] + 0.3*s[k-3] + 100*s[k-4]
d = d[4: ]
x = pa.input_from_history(s, n) # prep the input to filter
# prep and train the filter
f = pa.filters.FilterLMS(mu=0.4, n=n)
y, e, w = f.run(d, x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment