@@ -26,13 +26,13 @@ function (callback::WeightedParticleRecorderCallback)(
2626end
2727
2828function gen_trajectory (
29- rng:: Random.AbstractRNG ,
30- model:: StateSpaceModel ,
29+ rng:: Random.AbstractRNG ,
30+ model:: StateSpaceModel ,
3131 particles:: AbstractMatrix{T} , # Need better container
32- log_weights:: AbstractMatrix{WT} ,
32+ log_weights:: AbstractMatrix{WT} ,
3333 forward_state,
3434 n_timestep:: Int ;
35- kwargs...
35+ kwargs... ,
3636) where {T,WT}
3737 trajectory = Vector {T} (undef, n_timestep)
3838 trajectory[end ] = forward_state
@@ -51,7 +51,6 @@ function gen_trajectory(
5151 return trajectory
5252end
5353
54-
5554function backward (
5655 model:: StateSpaceModel , step:: Integer , state, particles:: T , log_weights:: WT ; kwargs...
5756) where {T,WT}
@@ -61,7 +60,6 @@ function backward(
6160 return log_weights + transitions
6261end
6362
64-
6563function sample (
6664 rng:: Random.AbstractRNG ,
6765 model:: StateSpaceModel{T,LDT} ,
@@ -71,7 +69,6 @@ function sample(
7169 callback= nothing ,
7270 kwargs... ,
7371) where {T,LDT,N}
74-
7572 n_timestep = length (obs)
7673 recorder = WeightedParticleRecorderCallback (
7774 Array {eltype(model.dyn)} (undef, n_timestep, N), Array {T} (undef, n_timestep, N)
@@ -85,7 +82,14 @@ function sample(
8582
8683 trajectories[end , :] = particles. filtered[idx_ref]
8784 for j in 1 : M
88- trajectories[:, j] = gen_trajectory (rng, model, recorder. particles, recorder. log_weights, trajectories[end , j], n_timestep)
85+ trajectories[:, j] = gen_trajectory (
86+ rng,
87+ model,
88+ recorder. particles,
89+ recorder. log_weights,
90+ trajectories[end , j],
91+ n_timestep,
92+ )
8993 end
9094 return trajectories
9195end
0 commit comments