Skip to content

Commit

Permalink
Completed 1d case
Browse files Browse the repository at this point in the history
  • Loading branch information
Rishi Juneja committed Aug 7, 2012
0 parents commit 57fe6d3
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions sgfilter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import numpy as np

def sgfilter1d(degree, window_size):
if not isinstance(degree, int) or degree < 0:
raise ValueError("Degree of polynomial must be positive integers")
if not isinstance(window_size, int) or window_size % 2 == 0 or window_size < 0 :
raise ValueError("Window size must be positive odd integer")
if window_size < degree + 2:
raise ValueError("Degree to high for half width")
A = np.mat([[n ** i for i in range(degree + 1)] for n in range(-(window_size - 1)/2, (window_size - 1)/2 + 1)])
Ainv = np.linalg.pinv(A)
return Ainv[0]

0 comments on commit 57fe6d3

Please sign in to comment.