# Particle Filtering: Derivation that mean of weights is the marginal likelihood

I see everywhere the following (for the Bootstrap Filter) $$p(y_t \mid y_{1:t-1}) \approx \frac{1}{N} \sum_{i=1}^N W(x_{0:t}^i)$$ where $$W(x_{0:t}^i)$$ are the normalized weights defined as

$$W(x_{0:t}^i) = \frac{w(x_{0:t}^i)}\sum_{i=1}^N w(x_{0:t}^j)}$$

where the normalized weights are $$w^i(x_{0:t}) = \frac{p(x_{0:t}^i \mid y_{1:t})}{q(x_{0:t}^i \mid y_{1:t})}$$

Everyone says this is straightforward to derive, but I really can't. Here's my attemp

# My Attempt at solving the problem

\begin{align} p(y_t \mid y_{1:t-1}) &= \int p(y_t, x_{0:t} \mid y_{1:t-1}) dx_{0:t} \\ &= \int p(y_t \mid x_{0:t}) p(x_{0:t} \mid y_{1:t-1}) d x_{0:t} \\ &= \int p(y_t \mid x_t) p(x_t \mid x_{0:t-1} )p(x_{0:t-1} \mid y_{1:t-1}) d x_{0:t} && \text{y_t cond. indep.} \\ &= \int p(y_t \mid x_t)p(x_t \mid x_{t-1})p(x_{0:t-1} \mid y_{1:t-1}) dx_{0:t} && \text{x_t markovian} \\ &\approx \int p(y_t \mid x_t) p(x_t \mid x_{t-1}) \widehat{p}_N(x_{0:t-1}\mid y_{1:t-1}) d x_{0:t} && \text{empirical distr.} \\ &= \int p(y_t\mid x_t)p(x_t\mid x_{t-1}) \sum_{i=1}^N W(x_{0:t-1}^i)\delta_{x_{0:t-1}^i}(x_{0:t-1}) dx_{0:t} \\ &= \sum_{i=1}^N \int p(y_t\mid x_t)p(x_t\mid x_{t-1})W(x_{0:t-1}^i)\delta_{x_{0:t-1}^i}(x_{0:t-1}) dx_{0:t} \\ &= \sum_{i=1}^N \int p(y_t, x_t \mid x_{0:t-1}) W(x_{0:t-1}^i)\delta_{x_{0:t-1}^i}(x_{0:t-1}) dx_{0:t-1} dx_t \\ &= \sum_{i=1}^N \int p(y_t , x_t\mid x_{0:t-1}^i) W(x_{0:t-1}^i) dx_t \\ &= \sum_{i=1}^N p(y_t \mid x_{0:t-1}^i)W(x_{0:t-1}^i) \end{align}

where I have used the empirical approximation $$\widehat{p}_N(x_{0:t}) = \sum_{i=1}^N W(x_{0:t}^i)\delta_{x_{0:t}^i}(x_{0:t})$$