update README.md in javascript
[liba.git] / python / test / lpf.py
blobb014388de741a552f18f8516976bc44ee36a1c39
1 #!/usr/bin/env python
2 import os, sys, math, random
4 base = os.path.dirname(__file__)
5 path = os.path.dirname(base)
6 sys.path.insert(0, path)
7 if len(sys.argv) > 1:
8 sys.stdout = open(sys.argv[1], "w")
10 import liba # type: ignore
12 N = 100
13 x = [0.0] * N
14 T = math.pi * 0.1
15 lpf = liba.lpf(10, 0.01)
16 for i in range(N):
17 x[i] = i * T
18 x1 = math.sin(x[i]) + 0.2 * (random.random() - 0.5)
19 print("%g,%g,%g" % (x[i], x1, lpf(x1)))
21 lpf.zero()
22 lpf.alpha
23 lpf.output