-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Rishi Juneja
committed
Aug 7, 2012
0 parents
commit 57fe6d3
Showing
1 changed file
with
12 additions
and
0 deletions.
There are no files selected for viewing
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
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] |