def kf_sim(sim):
"""
Process each simulation trial generated with
:func:`setup_random_test` with a Kalman filter and return the
posterior state estimates and error covariances.
"""
post = defaultdict(dict)
for l in range(sim['L']):
x_hat_l, P_l = kalman_filter(sim[l]['y'],
sim['H'],
sim['R'],
sim['F'],
sim['Q'],
sim['mu'],
sim['PI'])
post[l]['x_hat'] = x_hat_l
if l == 0:
post['P'] = P_l
post[l]['error'] = []
for x_i, x_hat_i in izip(sim[l]['x'], post[l]['x_hat']):
post[l]['error'].append(x_hat_i - x_i)
return post
评论列表
文章目录