# Particle filter - expectations

I've recently been implementing some particle filter algorithms and I've realized there is a small detail I might have been doing incorrectly. Unfortunately the descriptions of the algorithms in papers seem a bit ambiguous (at least to me) and if I try to simulate it to see which way might be correct, both ways of doing it perform reasonably well.

So here is the question specifically, at time $t$ we are approximating an expectation with a weighted sum, let $M$ denote the number of particles and $t$ denote the time step:

$$\psi_t = \sum_{i=1}^M w_t^{(i)}(x_i)f_t^{(i)}(x_i)$$

now my question is about the propagation of this approximation, on time $t+1$ do I now set all particles equal to $\psi_t$ and continue on with the other computations for $t+1$, or is the weighted sum only used "at the end"?

That might not make sense as my explanations are not the best so maybe it's clearly in pseudocode in it's algorithmic form:

# tf() is the transition function that generates new particles
# it is t(x_t | x_{t-1}) where x's are particles
# lik() is the function that calculates the importance weights

set y = [y_1, ... y_N] # observations

for time = 1:N
# assume these are all vector operations so all paticles 1:M are
# being updated below
new_particles_{time} = tf(old_particles_{time-1})
weights_{time} = lik(y_{time}, new_particles_{time})
new_particles_{time} = systematic_resample(new_particles_{time}, weights_{time})
expectation = sum(new_particles_{time} * weights_{time})
# do I do this below:
old_particles_{time} = [expectation for particle_idx = 1:M]  #(1)
# or do I do this:
old_particles_{time} = new_particles_{time} * weights_{time}  #(2)
# or maybe I do none and just do:
old_particles_{time} = new_particles_{time}  #(3)
end


so in the code above, the question is do I do #(1), #(2), or #(3) Additionally, should I be computing the expectation before the re sampling step or after?

• What does $f$ mean in the equation above? – Zach Sep 11 '18 at 2:03
• A good practical introduction to particle filters in robotics is Probabilistic Robotics by Thrun, Burgard, and Fox – Zach Sep 11 '18 at 2:04
• @atomsmasher when you write $\psi_t = \sum_{i=1}^M w_t^{(i)}(x_i)f_t^{(i)}(x_i)$, why does $f$ depend both on the particle and on time? That's unusual. And how you use your particles shouldn't affect how you update them (propogate, reweight, resample, etc). Those are two separate things – Taylor Sep 11 '18 at 3:15

 weights_{time} = weights_{time-1} * lik(y_{time}, new_particles_{time})