Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- # returns a simple lowpass filter function, based on the specified parameters
- def filterA(alpha, initial):
- def f(x):
- f.prev = x * (1.0 - alpha) + f.prev * alpha
- return f.prev
- f.prev = initial
- return f
- # create some test signal
- testSignal = [math.sin(0.25 * x) for x in range(20)]
- # see the result of applying two of these filters, chained together, on the
- # test signal
- print(map(filterA(alpha=0.95, initial=7.5), map(filterA(alpha=0.99, initial=-1.5), testSignal)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement