# Computing Monte Carlo Error: Particle Filters

I want to ask a question about the Monte Carlo error of a particle filter. Assume we have information of our of the process of our true states, $$x_t \forall t$$ and hence, we generate our data $$y_t$$. (Once we obtain $$y_t$$ we keep it fixed.)

Now, I am running a generic particle filter (using the prior proposal) with resampling. I run the filter with a resampling step occasionally when $$N_{eff}, where $$N$$ is the number of particles used at each time step, $$N_{thr}$$ is some specified threshold, and $$N_{eff}=\frac{1}{\sum(w^{i}_{t})^2}$$ at time $$t$$.

Note: we are using the particle filter to estimate the filtered distribution , $$p(x_{t}|y_{1:t})$$, hence, resampling is performed on particles of each state and the paths are not resampled. For further notation, let $$x_t$$ denote the states and $$y_t$$ denote the measurement generated by $$x_t$$. My particle filter algorithm has this structure. (Note that the $$i$$ superscript is the index of particle.)

At time $$t$$, $$\forall i=1\dots N$$

1. We know $$x^i_{t-1}$$
2. Project $$x^i_{t-1}$$ to $$x^i_{t}$$ using process model $$p(x_t|x_{t-1})$$
3. Compute weight $$w^i_t$$
4. If $$N_{eff} then resample $$\{x^i_t\}$$ according to $$\{w^i_{t}\}$$

Continue process at time $$t+1$$.

I want to know:

1) How to calculate the monte carlo error of the mean for the filter state $$x_t|y_{1:t}$$?

My understanding is that the monte carlo error is the variance of the distribution of the mean or the error if the filter is run through multiple times (some sort of generalisation error). I understand the central limit theorem is a way to obtain the monte carlo error, ie $$\bar{x}=\operatorname{mean}(\{x_t^i\}) \sim N(\mu, \frac{\sigma^2}{N})\,.$$ We can do this as long as $$x^i_t$$ are independent from each other. I read somewhere that the particles $$x^i_t$$ are independent but not identically distributed, hence, we can in fact apply the central limit theorem if the weights $$w_t^i$$ are equal.

Note: I cannot gain an estimate for the Monte Carlo error when the weights are unequal. Therefore, I think one way is to simulate the Monte Carlo error by taking $$M$$ simulations of the filter. For example, say we are interested in the Monte Carlo error of $$\bar{x}_k$$, while using the same $$y_t \forall t$$ for each simulation as described above, I run the filter $$M$$ times and compute the mean for the time step I am interested in. With these collections of means $$\bar{x}_k$$ for $$i=1\dots N$$, I can obtain the Monte Carlo error estimate by taking standard deviation of all my means. Is this done correctly?

My next two questions are dependent on the answer to the above question.

2) If I understand correctly, the Monte Carlo error estimate of the simulation I did above, accounts for the Monte Carlo error accumulated from time step, $$t=1 \dots k$$. Therefore, if I resample more often between $$t=1 \dots k$$ I should get a higher Monte Carlo error estimate as compared if I resampled less often.

However, I obtained different results, i.e. the more I resample the lower the Monte Carlo error is. Is there a reason why?

Is it like this perhaps because computing the standard deviation of the means only incorporates the variation for time state $$k$$ and I have not accounted for variation for time state of the previous time steps?

3) What if I wanted to compute the Monte Carlo error of the mean of the trajectories, i.e. $$\bar{x}_1,\bar{x}_2, \dots , \bar{x}_k$$.

How would I compute the standard deviation of the means (which is a vector)?.

4) Was it correct that I did not re-simulate data $$y_t$$ and that I kept it fixed through all $$M$$ simulations?

My thinking was that the filter was already random so I did not have to re-generate, although I am worried that the Monte Carlo error which is used to generalize the filter efficiency may not be representative of other type of data.