# Particle Filter

Particle filter is a non-parametric filter. The main idea is to use "particles" to represent the distribution. The algorithm involves sampling data from a given distribution. To some extent, we can view it as a mini simulation.

Before presenting the pseudo code, let's first see an example. Suppose we have a state graph where a node represents a state and an edge represents the station transition. Each edge has a weight which corresponds to the probability of the transition from the source state to the destination state.

<figure><img src="/files/fo2i46hERQ6FadkQvOOm" alt="" width="375"><figcaption></figcaption></figure>

For example, the first state is the start state, there is a 80% chance it will go to the A1 state and another 20% chance to the A2 state. Now, the question is how we can figure our the distribution of states in the third level (i.e. B1, ..., B5). If the transition graph is simple, we may be able to manually calculate the distribution of states. As things are often complicated in real world, it can be challenging to come with the closed-form of the distribution. An alternative is to simulate the state transition. At a given state, we generate a sample of next state according to the transition probability. We repeat this process until we have sufficient data to approximate the real distribution.

<figure><img src="/files/GvkopRIh5EbzgYmtmAn9" alt="" width="375"><figcaption></figcaption></figure>

#### Particle Filter Algorithm

<figure><img src="/files/q3rqVvHdlHmdIcwfYjOm" alt=""><figcaption><p>(source: Probabilistic Robotics)</p></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.learnros2.com/probabilistic-robotics/particle-filter.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
