Skip to content

Instantly share code, notes, and snippets.

@zmeri
zmeri / gist:3c43d3b98a00c02f81c2ab1aaacc3a49
Last active June 22, 2022 10:05
This is a function that implements a Whittaker smoother in Python. Reference: Paul H. C. Eilers. "A Perfect Smoother". Analytical Chemistry, 2003, 75 (14), pp 3631–3636.
import scipy as sp
import scipy.sparse
import scipy.linalg
from scipy.sparse.linalg import cg
def whitsm(y, lmda):
m = len(y)
E = sp.sparse.identity(m)
d1 = -1 * np.ones((m),dtype='d')
d2 = 3 * np.ones((m),dtype='d')