Advertisement
Guest User

Untitled

a guest
Nov 2nd, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. import math
  2.  
  3. # returns a simple lowpass filter function, based on the specified parameters
  4. def filterA(alpha, initial):
  5. def f(x):
  6. f.prev = x * (1.0 - alpha) + f.prev * alpha
  7. return f.prev
  8. f.prev = initial
  9. return f
  10.  
  11. # create some test signal
  12. testSignal = [math.sin(0.25 * x) for x in range(20)]
  13.  
  14. # see the result of applying two of these filters, chained together, on the
  15. # test signal
  16. 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