def single_estimate(sigin, f, fs, hmax):
"""Estimate the contribution of electrical network
signal in sigin, if ENF is f.
return the estimated signal
"""
X = np.empty((len(sigin), hmax))
fact = 2.0 * np.pi * f / fs * np.arange(1, hmax + 1)[:, None]
p = np.arange(len(sigin))[:, None]
X = np.dot(fact, p.T)
X = np.concatenate([X, X + np.pi / 2]).T
X = np.cos(X)
XX = np.dot(X.T, X)
Xy = np.dot(X.T, sigin)
theta = linalg.solve(XX, Xy)
return np.dot(X, theta)
评论列表
文章目录