Last active
March 30, 2021 22:14
-
-
Save netsatsawat/f9c4d822d1d6c174740e499eb3400fa3 to your computer and use it in GitHub Desktop.
Basic example using mock data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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