The simplest approach to the generation of particles is forward sampling. In the case of forward sampling, we generate random samples , , …, from the distribution P(X).
Let's take the example of generating particles using our restaurant model:
We start by simply selecting a state of the variable Location with the probabilities 0.6 and 0.4. Let's say we select the location of the restaurant to be good and select the quality to be good as well. Now, knowing the observed states of Location and Quality, we can now select the state of Cost to be high with the probability 0.8 and low with the probability 0.2. Similarly, selecting a state for No. of People, we will get a single full particle over our restaurant model. To generate M particles, we repeat the same process M times to get M instantiations of the variables.
The main thing to notice is that we start with sampling variables that have no parents, and do it in an order such that before we sample any variable, we already have the values for all the parents of that variable.
After generating some particles, we can estimate the expectation of some function f using these particles as follows:
Now, for a case when we want to compute the probability of some event Y = y, using these particles, we can simply calculate the fraction of particles satisfying the event. So, we can compute the probability P(Y = y) as follows:
So, taking the example of our restaurant model and computing the probability of Cost to be high, of the restaurant is equivalent to getting the fraction of particles satisfying these values:
The key points to note in the case of particle methods are as follows: