def run_random_sim(sim, L):
"""
Run *L* simulations of the state space model specified by *sim*
(see :func:`setup_random_sim`). Each simulation is added to *sim*
index by an integer identifier.
"""
sim['L'] = L
for l in range(L):
sim[l] = defaultdict(list)
x_i = sim['mu'] + NP.matmul(sim['PI_sqrt'], NP.random.randn(sim['N']))
for i in range(sim['I']):
sim[l]['x'].append(x_i)
# measurement
v_i = NP.matmul(sim['R_sqrt'][i], NP.random.randn(sim['M']))
sim[l]['y'].append(NP.matmul(sim['H'][i], sim[l]['x'][i]) + v_i)
# time update
u_i = NP.matmul(sim['Q_sqrt'][i], NP.random.randn(sim['N']))
x_i = NP.matmul(sim['F'][i], x_i) + u_i
return sim
评论列表
文章目录