# Very simple particle filters algorithm (sequential monte carlo method) implementation

I'm interested in the simple algorithm for particles filter given here. It seems very simple but I have no idea on how to do it practically. Any idea on how to implement it (just to better understand how it works) ?

Edit: This is a great simple example that explain how it works. I've tried to implement it in C++: see my code here, but I'm note sure if I do it the right way. Can you please check if I understood it well, or there are some misunderstanding according to my code ?

-
I am not trying to go into your question in any detail but the example you cite seems obvious to me. p(xt|x(i)t−1) is a conditional probability distribution and the statement is simple to draw x(i)t from that conditional probability distribution. –  Michael Chernick May 7 '12 at 15:13
@MichaelChernick well, I've edited my post to add a simple C++ implementation of a simple example. Can you please check if I understood it well, or there are some misunderstanding ? –  shn May 10 '12 at 11:22

What that sentence means is you should generate $x_t^{(i)}$ from the distribution of $p(x_t|x^{(i)}_{t−1})$.

For an alternative introduction to particle filters I recommend An Overview of Existing Methods and Recent Advances in Sequential Monte Carlo

MATLAB has numerous toolboxes on particle filters. If you are working in C++, here is an implementation you can use to compare your code with.

-
Ok, thanks for this resources. Well, I want to implement particle filters alone from scrach just to understand it. I've edited my post to add a simple C++ implementation of a simple example. Can you please check if I understood it well, or there are some misunderstanding ? –  shn May 10 '12 at 11:24
I can't error-check it mentally and I don't have the time to compile it. I suggest you test it with synthetic data and check the reference code I just provided. –  Emre May 10 '12 at 23:44
The other implementations seems complicated, I just wanted to implement this "very" simple one: aiqus.com/upfiles/PFAlgo.png on an example with two states. If I provide the algorithm of how I understood it (instead of code) can you check it ? –  shn May 11 '12 at 8:51
What does it mean when one say: "Sample N times with replacement from the set of particles $x_t^{(i)}$ according to importance weights $w_t^{(i)}$ –  shn May 14 '12 at 13:13
It means you should sample with replacement with a probability of selecting a particle proportional to its weight. See this tutorial by Sebastian Thrun. –  Emre May 18 '12 at 1:14