def analysis(N, M, I, L, sqrt=False):
"""
Conduct a Kalman filter validation experiment. Output results
(concerning the error, i.e., x_hat - x) for the last time step
only. If *sqrt* use the square root form Kalman filter.
"""
sim = setup_random_test(N, M, I, L)
if sqrt:
post = sqrt_kf_sim(sim)
else:
post = kf_sim(sim)
# output statistics of \hat{x}_{I|I}
error_I = []
for l in range(sim['L']):
error_I.append(post[l]['error'][-1])
E_I = NP.stack(error_I, 1)
E_I_mean = NP.mean(E_I, 1)
P_I = NP.cov(E_I)
print('Mean of error at time step I={}'.format(I))
for E_I_mean_n in E_I_mean:
print('{:9.2e}'.format(E_I_mean_n))
print('')
print('True posterior covariance at time step I')
print(NP.array_str(post['P'][-1], precision=2))
print('')
print('Empirical posterior covariance at time step I')
print(NP.array_str(P_I, precision=2))
return sim, post
评论列表
文章目录