def residual(xi, n, input_lags): d1i = xi.reshape(n, n).transpose() / mu m = MAP(D0, d1i, check=False) estimated_lags = [m.lag(i + 1) for i in range(len(input_lags))] system_diff = np.asarray(A.dot(xi) - b).flatten() * 1000 lags_diff = np.asarray(input_lags - estimated_lags) diff = np.hstack((system_diff, lags_diff)) return diff
def residual(x, n, input_moments, input_lags): m = MAP(*decompose(x, n), check=False) estimated_moments = [ m.moment(i + 1) for i in range(len(input_moments)) ] estimated_lags = [m.lag(i + 1) for i in range(len(input_lags))] estimated_moments_lags = np.r_[estimated_moments, estimated_lags] input_moments_lags = np.r_[input_moments, input_lags] return estimated_moments_lags - input_moments_lags