1
1
export AuxiliaryParticleFilter, APF
2
2
3
- struct AuxiliaryParticleFilter{RS<: AbstractConditionalResampler } <: AbstractFilter
3
+ mutable struct AuxiliaryParticleFilter{RS<: AbstractConditionalResampler } <: AbstractFilter
4
4
N:: Integer
5
5
resampler:: RS
6
6
aux:: Vector # Auxiliary weights
7
7
end
8
8
9
9
function AuxiliaryParticleFilter (
10
- N:: Integer , threshold:: Real = 1.0 , resampler:: AbstractResampler = Systematic ()
10
+ N:: Integer ; threshold:: Real = 1.0 , resampler:: AbstractResampler = Systematic ()
11
11
)
12
12
conditional_resampler = ESSResampler (threshold, resampler)
13
13
return AuxiliaryParticleFilter (N, conditional_resampler, zeros (N))
@@ -25,7 +25,7 @@ function initialise(
25
25
initial_states = map (x -> SSMProblems. simulate (rng, model. dyn; kwargs... ), 1 : (filter. N))
26
26
initial_weights = fill (- log (T (filter. N)), filter. N)
27
27
28
- return update_ref! (ParticleContainer (initial_states, initial_weights), ref_state)
28
+ return update_ref! (ParticleContainer (initial_states, initial_weights), ref_state, filter )
29
29
end
30
30
31
31
function update_weights! (
@@ -57,16 +57,16 @@ function predict(
57
57
auxiliary_weights = map (
58
58
x -> SSMProblems. logdensity (model. obs, step, x, observation; kwargs... ), predicted
59
59
)
60
- state . filtered. log_weights .+ = auxiliary_weights
60
+ states . filtered. log_weights .+ = auxiliary_weights
61
61
filter. aux = auxiliary_weights
62
62
63
- states. proposed = resample (rng, filter. resampler, states. filtered, filter)
63
+ states. proposed, states . ancestors = resample (rng, filter. resampler, states. filtered, filter)
64
64
states. proposed. particles = map (
65
65
x -> SSMProblems. simulate (rng, model. dyn, step, x; kwargs... ),
66
66
states. proposed. particles,
67
67
)
68
68
69
- return update_ref! (states, ref_state, step)
69
+ return update_ref! (states, ref_state, filter, step)
70
70
end
71
71
72
72
function update (
0 commit comments