def __gausscoeff(s):
"""Python implementation of the algorithm by Young & Vliet, 1995."""
if s < .5:
raise ValueError('Sigma for Gaussian filter must be >0.5 samples')
q = 0.98711*s - 0.96330 if s > 0.5 else 3.97156 \
- 4.14554*np.sqrt(1.0 - 0.26891*s)
b = np.zeros(4)
b[0] = 1.57825 + 2.44413*q + 1.4281*q**2 + 0.422205*q**3
b[1] = 2.44413*q + 2.85619*q**2 + 1.26661*q**3
b[2] = -(1.4281*q**2 + 1.26661*q**3)
b[3] = 0.422205*q**3
B = 1.0 - ((b[1] + b[2] + b[3])/b[0])
# convert to a format compatible with lfilter's
# difference equation
B = np.array([B])
A = np.ones(4)
A[1:] = -b[1:]/b[0]
return B, A
评论列表
文章目录