\section{Smoothing}
\label{sec:smoothing}



The main purpose of this work is to provide smoothing methods in context of indoor localisation.
As mentioned before, those algorithm are able to compute probability distributions in the form of $p(\mStateVec_t \mid \mObsVec_{1:T})$ and are therefore able to make use of future observations between $t$ and $T$. 
%Especially fixed-lag smoothing is very promising in context of pedestrian localisation. 
In the following we discuss the algorithmic details of the forward-backward smoother and the backward simulation. 
Further, two novel approaches for incorporating them into the localisation system are shown.

\subsection{Forward-backward Smoother}

The forward-backward smoother (FBS) of \cite{Doucet00:OSM} is a well established alternative to the simple filter-smoother. The foundation of this algorithm was again laid by Kitagawa in \cite{kitagawa1987non}. 
An approximation is given by
\begin{equation}
p(\vec{q}_t \mid \vec{o}_{1:T}) \approx \sum^N_{i=1} W^i_{t \mid T} \delta_{\vec{X}^i_{t}}(\vec{q}_{t}) \enspace, 
\end{equation}
where $p(\vec{q}_t \mid \vec{o}_{1:T})$ has the same support as the filtering distribution $p(\vec{q}_t \mid \vec{o}_{1:t})$, but the weights are different. 
This means, that the FBS maintains the original particle locations and just reweights the particles to obtain a smoothed density. 
The complete FBS can be seen in algorithm \ref{alg:forward-backwardSmoother} in pseudo-algorithmic form. 
At first, the algorithm obtains the filtered distribution (particles) by deploying a forward step at each time $t$. 
Then the backward step for determining the smoothing distribution is carried out.
The weights are obtained through the backward recursion in line 9.


\begin{algorithm}[t]
    \caption{Forward-Backward Smoother}
    \label{alg:forward-backwardSmoother}
    \begin{algorithmic}[1] % The number tells where the line numbering should start
		\Statex{\textbf{Input:} Prior $\mu(\vec{X}^i_1)$}
		\Statex{~}
			\For{$t = 1$ \textbf{to} $T$} \Comment{Filtering}
				\State{Obtain the weighted trajectories $ \{ W^i_t, \vec{X}^i_t\}^N_{i=1}$}
			\EndFor
			\For{ $i = 1$ \textbf{to} $N$} \Comment{Initialization}
				\State{Set $W^i_{T \mid T} = W^i_T$} 
			\EndFor
			\For{$t = T-1$ \textbf{to} $1$} \Comment{Smoothing}
				\For{$i = 1$ \textbf{to} $N$}
\vspace*{0.1cm}
					\State{
$
W^i_{t \mid T} = W^i_t \left[ \sum^N_{j=1} W^j_{t+1 \mid T} \frac{p(\vec{X}^j_{t+1} \mid \vec{X}^i_t)}{\sum^N_{k=1} W^k_t ~ p(\vec{X}^j_{t+1} \mid \vec{X}^k_t)} \right] 
$}
				\EndFor	
			\EndFor
    \end{algorithmic}
\end{algorithm}



%Probleme? Nachteile? Komplexität etc.
By reweighting the filter particles, the FBS improves the simple filter-smoother by removing its dependence on the inheritance (smoothed) paths \cite{fearnhead2010sequential}. However, by looking at algorithm \ref{alg:forward-backwardSmoother}  it can easily be seen that this approach computes in $\mathcal{O}(N^2)$, where the calculation of each particle's weight is an $\mathcal{O}(N)$ operation. To reduce this computational bottleneck, \cite{klaas2006fast} introduced a solution using algorithms from N-body simulation. By integrating dual tree recursions and fast multipole techniques with the FBS a run-time cost of $\mathcal{O}(N \log N)$ can be achieved. 

\subsection{Backward Simulation}
For smoothing applications with a high number of particles, it is often not necessary to use all particles for smoothing. This decision can for example be made due to a high sample impoverishment and/or highly certain sensors. By choosing a good sub-set for representing the posterior distribution, it is theoretically possible to further improve the estimation. 

Therefore, \cite{Godsill04:MCS} presented the \textit{backward simulation}. Where a number of independent sample realizations from the entire smoothing density are used to approximate the smoothing distribution. To derive the backward simulation algorithm we need to factorize the joint smoothing distribution as follows:
\begin{equation}
p(\vec{q}_{1:T} \mid \vec{o}_{1:T}) = p(\vec{q}_{T} \mid \vec{o}_{1:T}) \prod^{T-1}_{t=1} p(\vec{q}_{t} \mid \vec{q}_{t+1:T}, \vec{o}_{1:T})
\end{equation}
By using the Markov property of the model, we can write
\begin{equation}
\begin{split}
p(\vec{q}_{t} \mid \vec{q}_{t+1:T}, \vec{o}_{1:T}) &= p(\vec{q}_{t} \mid \vec{q}_{t+1}, \vec{o}_{1:t})\\
&= \frac{p(\vec{q}_{t} \mid \vec{o}_{1:t}) p(\vec{q}_{t+1} \mid \vec{q}_{t})}{p(\vec{q}_{t+1} \mid \vec{o}_{1:t})} \\
& \propto p(\vec{q}_{t} \mid \vec{o}_{1:t}) p(\vec{q}_{t+1} \mid \vec{q}_{t})
\enspace ,
\end{split}
\label{eq:backwardSimulation-02}
\end{equation}
where $p(\vec{q}_t \mid \vec{o}_{1:t})$ is obtained using any particle filter in the forward step. Using \ref{eq:backwardSimulation-02} the particles can be approximated as follows:
\begin{equation}
p(\vec{q}_{t} \mid \vec{q}_{t+1:T}, \vec{o}_{1:T}) \approx \sum^N_{i=1} W^i_{t \mid t+1} \delta_{\vec{X}^i_{t}}(\vec{q}_{t}) \enspace,
\end{equation}
where the weights are determined with
\begin{equation}
W^i_{t \mid t+1} = \frac{ W^i_t ~ p(\vec{q}_{t+1} \mid \vec{X}^i_{t})}{\sum^N_{j=1} W^j_t p(\vec{q}_{t+1} \mid \vec{X}^j_{t})}\enspace .
\end{equation}
This can now be used to generate states successively in the reverse-time direction, conditioning upon future states. 

\begin{algorithm}[t]
    \caption{Backward Simulation Smoothing}
    \label{alg:backwardSimulation}
    \begin{algorithmic}[1] % The number tells where the line numbering should start
		\Statex{\textbf{Input:} Prior $\mu(\vec{X}^i_1)$}
		\Statex{~}
			\For{$t = 1$ \textbf{to} $T$} \Comment{Filtering}
				\State{Obtain the weighted trajectories $ \{ W^i_t, \vec{X}^i_t\}^N_{i=1}$}
			\EndFor
			\For{ $k = 1$ \textbf{to} $N_{\text{sample}}$} 
				\State{Choose $\tilde{\vec{q}}^k_T = \vec{X}^i_T$ with probability $W^i_T$} \Comment{Initialize}
			
				\For{$t = T-1$ \textbf{to} $1$} \Comment{Smoothing}
					\For{$j = 1$ \textbf{to} $N$}
						\State{$W^j_{t \mid t+1} = W^j_t ~ p(\tilde{\vec{q}}_{t+1} \mid \vec{X}^j_{t})$}
					\EndFor	
				\State{Choose $\tilde{\vec{q}}^k_t = \vec{X}^j_t$ with probability $W^j_{t\mid t+1}$}
				\EndFor
				\State{$\tilde{\vec{q}}^k_{1:T} = (\tilde{\vec{q}}^k_1, \tilde{\vec{q}}^k_2, ..., \tilde{\vec{q}}^k_T)$ is one approximate realization from $p(\vec{q}_{1:T} \mid \vec{o}_{1:T})$}
			\EndFor
    \end{algorithmic}
\end{algorithm}

The backward simulation method can be seen in algorithm \ref{alg:backwardSimulation} in pseudo-algorithmic form. Again, a particle filter is performed at first and then the smoothing procedure gets applied. Here, $\tilde{\vec{q}}_t$ is a random sample drawn approximately from $p(\vec{q}_{t} \mid \tilde{\vec{q}}_{t+1}, \vec{o}_{1:T})$. Therefore $\tilde{\vec{q}}_{1:T} = (\tilde{\vec{q}}_{1}, \tilde{\vec{q}}_{2}, ...,\tilde{\vec{q}}_{T})$ is one particular sample realization from $p(\vec{q}_{1:T} \mid \vec{o}_{1:T})$. Further independent realizations are obtained by repeating the algorithm until the desired number $N_{\text{sample}}$ is reached. The computational complexity for one particular realization is $\mathcal{O}(N)$. However, the computations are then repeated for each realization drawn \cite{Godsill04:MCS}.

\subsection{Transition for Smoothing}


%komplexität eingehen
The reason for not behandeln liegt ... 
However, \cite{} and \cite{} have proven this wrong and reduced the complexity of different smoothing methods. 
