Renamed moving average filter to box filter
This commit is contained in:
@@ -107,9 +107,10 @@
|
||||
\newcommand{\dop} [1]{\ensuremath{ \mathop{\mathrm{d}#1} }}
|
||||
\newcommand{\R} {\ensuremath{ \mathbf{R} }}
|
||||
\newcommand{\Z} {\ensuremath{ \mathbf{Z} }}
|
||||
\newcommand{\N} {\ensuremath{ \mathbf{N} }}
|
||||
\newcommand{\expp} [1]{\ensuremath{ \exp \left( #1 \right) }}
|
||||
\newcommand{\landau}[1]{\ensuremath{ \mathcal{O}\left( #1 \right) }}
|
||||
\newcommand{\wideal} {\ensuremath{ w_{\text{ideal}} }}
|
||||
\newcommand{\Lideal} {\ensuremath{ L_{\text{ideal}} }}
|
||||
\newcommand{\floor} [1]{\ensuremath{ \lfloor #1 \rfloor }}
|
||||
\newcommand{\etal} [1]{#1~et~al.}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ However, in complex scenarios this frequently results in a poor representation,
|
||||
Recovering the probability density function using a kernel density estimation yields a promising approach to find the \qq{real} most probable state, but comes with high computational costs.
|
||||
Especially in time critical and time sequential scenarios, this turns out to be impractical.
|
||||
Therefore, this work uses techniques from digital signal processing in the context of estimation theory, to allow rapid computations of kernel density estimates.
|
||||
The gains in computational efficiency are realized by substituting the Gaussian filter with an approximate filter based on the moving average filter.
|
||||
The gains in computational efficiency are realized by substituting the Gaussian filter with an approximate filter based on the box filter.
|
||||
Our approach outperforms other state of the art solutions, due to a fully linear complexity \landau{N} and a negligible overhead, even for small sample sets.
|
||||
Finally, our findings are tried and tested within a real world sensor fusion system.
|
||||
\end{abstract}
|
||||
|
||||
@@ -118,7 +118,7 @@ Using the Gaussian kernel from \eqref{eq:gausKern} in conjunction with \eqref{eq
|
||||
The above formula is a convolution operation of the data and the Gaussian kernel.
|
||||
More precisely it is a discrete convolution of the finite data grid and the Gaussian function.
|
||||
In terms of DSP this is analogous to filter the binned data with a Gaussian filter.
|
||||
This finding allows to speedup the computation of the density estimate by using a fast approximation scheme based on iterated moving average filters.
|
||||
This finding allows to speedup the computation of the density estimate by using a fast approximation scheme based on iterated box filters.
|
||||
|
||||
|
||||
\commentByToni{hier vielleicht nochmal explizit erwähnen, also mit Namen, das der Gauss jetzt die BKDE approximiert und das diese erkenntniss toll und wichtig ist, weil wir so ein komplexes problem total einfach und schnell dargestellt haben. \commentByMarkus{Reicht das so?}}
|
||||
|
||||
@@ -20,77 +20,84 @@ Such a restriction is superfluous in the context of digital filters, so the norm
|
||||
|
||||
Computation of a digital filter using the a naive implementation of the discrete convolution algorithm yields $\landau{NM}$, where $N$ is the length of the input signal and $M$ is the size of the filter kernel.
|
||||
In order to capture all significant values of the Gaussian function the kernel size $M$ must be adopted to the standard deviation of the Gaussian.
|
||||
A faster $\landau{N}$ algorithm is given by the well-known approximation scheme based on iterated moving average filters.
|
||||
While reducing the algorithmic complexity this approximation also reduces computational time significantly due to the simplistic computation scheme of the moving average filter.
|
||||
Following that, a implementation of the iterated moving average filter is one of the fastest ways to obtain an approximative Gaussian filtered signal.
|
||||
A faster $\landau{N}$ algorithm is given by the well-known approximation scheme based on iterated box filters.
|
||||
While reducing the algorithmic complexity this approximation also reduces computational time significantly due to the simplistic computation scheme of the box filter.
|
||||
Following that, a implementation of the iterated box filter is one of the fastest ways to obtain an approximative Gaussian filtered signal.
|
||||
% TODO mit einem geringen Fehler
|
||||
% TODO und somit kann der mvg filter auch die BKDE approxen?
|
||||
|
||||
\subsection{Moving Average Filter}
|
||||
The moving average filter is a simplistic filter which takes an input function $x$ and produces a second function $y$.
|
||||
A single output value is computed by taking the average of a number of values symmetrical around a single point in the input.
|
||||
The number of values in the average can also be seen as the width $w=2r+1$, where $r$ is the \qq{radius} of the filter.
|
||||
The computation of an single output value using a moving average filter of radius $r$ is defined as
|
||||
\subsection{Box Filter}
|
||||
The box filter is a simplistic filter defined as convolution of the input signal and the box (or rectangular) function.
|
||||
A discrete box filter of \qq{radius} $l\in N_0$ is given as
|
||||
\begin{equation}
|
||||
\label{eq:symMovAvg}
|
||||
y[i]=\frac{1}{2r+1} \sum_{j=-r}^{r}x[i+j] \text{.}
|
||||
\label{eq:boxFilt}
|
||||
y[n] = \sum_{k=0}^{L-1} x[k] B_L(n-k)
|
||||
\end{equation}
|
||||
where $L=2l+1$ is the width of the filter and
|
||||
\begin{equation}
|
||||
\label{eq:boxFx}
|
||||
B_L(n)=
|
||||
\begin{cases}
|
||||
L^{-1} & \text{if } -l \le n \le l \\
|
||||
0 & \text{else }
|
||||
\end{cases}
|
||||
\end{equation}
|
||||
is the discrete box kernel.
|
||||
|
||||
Such a filter requires clearly $\landau{Nw}$ operations, where $N$ is the signal length.
|
||||
It is well-known that a moving average filter can approximate a Gaussian filter by repetitive recursive computations.
|
||||
\eqref{eq:symMovAvg} is equal to convolution of the input signal and the rectangular function.
|
||||
Such a filter clearly requires $\landau{NL}$ operations, where $N$ is the input signal length.
|
||||
It is well-known that a box filter can approximate a Gaussian filter by repetitive recursive computations.
|
||||
Given by the central limit theorem of probability, repetitive convolution of a rectangular function with itself eventually yields a Gaussian in the limit.
|
||||
Likewise, filtering a signal with the moving average filter in several passes approximately converges to a Gaussian filter.
|
||||
Likewise, filtering a signal with the box filter several times approximately converges to a Gaussian filter.
|
||||
In practice three or five iterations are most likely enough to obtain a reasonable close Gaussian approximation \cite{kovesi2010fast}.
|
||||
|
||||
This allows rapid approximation of the Gaussian filter using the moving average filter, which only requires a few addition and multiplication operations.
|
||||
This allows rapid approximation of the Gaussian filter using box filter, which only requires a few addition and multiplication operations.
|
||||
Opposed to the Gaussian filter where several evaluations of the exponential function are necessary.
|
||||
The most efficient way to compute a single output value of the moving average is:
|
||||
The most efficient way to compute a single output value of the box filter is:
|
||||
\begin{equation}
|
||||
\label{eq:recMovAvg}
|
||||
y[i] = y[i-1] + x[i+r] - x[i-r-1]
|
||||
\end{equation}
|
||||
This recursive calculation scheme further reduces the time complexity of the moving average filter to $\landau{N}$, by reusing already calculated values.
|
||||
This recursive calculation scheme further reduces the time complexity of the box filter to $\landau{N}$, by reusing already calculated values.
|
||||
Furthermore, only one addition and subtraction is required to calculate a single output value.
|
||||
|
||||
|
||||
Given a fast approximation scheme, it is necessary to construct a box filter analogous to a given Gaussian filter.
|
||||
The solely parameter of the Gaussian kernel is the standard deviation $\sigma$.
|
||||
In contrast, the moving average filter is parametrized by its width $w$.
|
||||
Therefore, in order to approximate the Gaussian filter of a given $\sigma$ a corresponding value of $w$ must be found.
|
||||
Given $n$ iterations of moving average filters with identical widths the ideal width $\wideal$, as suggested by Wells~\cite{wells1986efficient}, is
|
||||
As seen in \eqref{eq:gausFilt}, the solely parameter of the Gaussian kernel is the standard deviation $\sigma$.
|
||||
In contrast, the box function \eqref{eq:boxFx} is parametrized by its width $L$.
|
||||
Therefore, in order to approximate the Gaussian filter of a given $\sigma$ a corresponding value of $L$ must be found.
|
||||
Given $n$ iterations of box filters with identical sizes the ideal size $\Lideal$, as suggested by Wells~\cite{wells1986efficient}, is
|
||||
\begin{equation}
|
||||
\label{eq:boxidealwidth}
|
||||
\wideal = \sqrt{\frac{12\sigma^2}{n}+1} \text{.}
|
||||
\Lideal = \sqrt{\frac{12\sigma^2}{n}+1} \text{.}
|
||||
\end{equation}
|
||||
|
||||
In general $\wideal$ can be any real number, but the moving average filter in \eqref{eq:symMovAvg} is restricted to odd integer values.
|
||||
In general $\Lideal$ can be any real number, but $B_L$ in \eqref{eq:boxFx} is restricted to odd integer values.
|
||||
Hence, the set of possible approximated standard deviations is limited, because the ideal width must be rounded to the next valid value.
|
||||
In order to reduce the rounding error Kovesi~\cite{kovesi2010fast} proposes to perform two box filters with different widths
|
||||
\begin{align}
|
||||
\label{eq:boxwidthtwo}
|
||||
\begin{split}
|
||||
w_l &=
|
||||
L_1 &=
|
||||
\begin{cases}
|
||||
\floor{w_{\text{ideal}}} - 1 & \text{if } \floor{w_{\text{ideal}}} \text{ is odd} \\
|
||||
\floor{w_{\text{ideal}}} & \text{else }
|
||||
\floor{\Lideal} - 1 & \text{if } \floor{\Lideal} \text{ is odd} \\
|
||||
\floor{\Lideal} & \text{else }
|
||||
\end{cases} \\
|
||||
w_u &= w_l + 2 \text{.}
|
||||
L_2 &= L_1 + 2 \text{.}
|
||||
\end{split}
|
||||
\end{align}
|
||||
|
||||
Given $w_l$ and $w_u$ the approximation is done by computing $m$ box filters of width $w_l$ followed by $(n-m)$ box filters of size $w_u$, where $0\le m\le n$.
|
||||
Given $L_1$ and $L_2$ the approximation is done by computing $m$ box filters of width $L_1$ followed by $(n-m)$ box filters of size $L_2$, where $0\le m\le n$.
|
||||
As all other values are known $m$ can be computed with
|
||||
\begin{equation}
|
||||
\label{eq:boxrepeatm}
|
||||
m=\frac{12\sigma^2-nw_l^2-4nw_l-3n}{-4w_l-4} \text{.}
|
||||
m=\frac{12\sigma^2-nL_1^2-4nL_1-3n}{-4L_1-4} \text{.}
|
||||
\end{equation}
|
||||
|
||||
The approximated $\sigma$ as a function of the integer width has a staircase shaped graph.
|
||||
By reducing the rounding error the step size of the function is reduced.
|
||||
However, the overall shape will not change.
|
||||
\etal{Gwosdek}~\cite{gwosdek2011theoretical} proposed an approach which allows to approximate any real-valued value of $\sigma$.
|
||||
Just like the conventional box filter, the extended version has a uniform value in the range $[-r; r]$, but unlike the conventional the extended box filter has different values at its edges.
|
||||
Just like the conventional box filter, the extended version has a uniform value in the range $[-l; l]$, but unlike the conventional the extended box filter has different values at its edges.
|
||||
This extension introduces only marginal computational overhead over conventional box filtering.
|
||||
|
||||
\commentByToni{Warum benutzen wir den extended box filter nicht? oder tun wir das? Liest sich so, als wäre er der heilige Gral.
|
||||
@@ -99,10 +106,6 @@ Ansonsten: Kapitel find ich gut. Vielleicht kann man hier und da noch paar sätz
|
||||
|
||||
\commentByToni{Aber irgendwie fehlt mir hier noch so ein Absatz oder Kapitel "Zusammenstecken" der Mathematik. Die Usage kommt wieder so Hart. Und nochmal eine kleine Diskussion zum Zusammenstecken. Vielleicht kann man das mit dem 2D verbinden? Weil aktuell haben wir die beiden Verfahren besprochen, aber der eigene Anteil ist irgendwie nicht ersichtlich. Was war jetzt deine tolle Leistung hier? Das muss durch eine gute Diskussion klar werden.}
|
||||
|
||||
\todo{box filter vs moving average filter vs einfahc eine Abkürzung? :D}
|
||||
|
||||
\commentByToni{Kann man eq(12) und eq(9) nicht irgendwie verbinden?}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -3,6 +3,59 @@
|
||||
\subsection{Extension to multi-dimensional data}
|
||||
\todo{Absatz zum Thema 2D - Extension to multi-dimensional data}
|
||||
|
||||
So far only univariate sample sets were considered.
|
||||
This is due to the fact, that the equations of the KDE \eqref{eq:kde}, BKDE \eqref{eq:binKde}, Gaussian filter \eqref{eq:gausFilt}, and the box filter \eqref{eq:boxFilt} are quite easily extended to multi-dimensional input.
|
||||
Each method can be seen as several one-dimensional problems combined to a multi-dimensional result.
|
||||
In the following, the generalization to multi-dimensional input are briefly outlined.
|
||||
|
||||
|
||||
In order to estimate a multivariate density using KDE or BKDE, a multivariate kernel needs to be used.
|
||||
Multivariate kernel functions can be constructed in various ways, however, a popular way is given by the product kernel.
|
||||
Such a kernel is constructed by combining several univariate kernels into a product, where each kernel is applied in each dimension with a possibly different bandwidth.
|
||||
|
||||
Given a multivariate random variable $X=(x_1,\dots ,x_d)$ in $d$ dimensions.
|
||||
The sample $\bm{X}$ is a $n\times d$ matrix defined as \cite[162]{scott2015}
|
||||
\begin{equation}
|
||||
\bm{X}=
|
||||
\begin{pmatrix}
|
||||
X_1 \\
|
||||
\vdots \\
|
||||
X_n \\
|
||||
\end{pmatrix}
|
||||
=
|
||||
\begin{pmatrix}
|
||||
x_{11} & \dots & x_{1d} \\
|
||||
\vdots & \ddots & \vdots \\
|
||||
x_{n1} & \dots & x_{nd}
|
||||
\end{pmatrix} \text{.}
|
||||
\end{equation}
|
||||
|
||||
The multivariate KDE $\hat{f}$ which defines the estimate pointwise at $\bm{x}=(x_1, \dots, x_d)^T$ is given as \cite[162]{scott2015}
|
||||
\begin{equation}
|
||||
\label{eq:mvKDE}
|
||||
\hat{f}(\bm{x}) = \frac{1}{W} \sum_{i=1}^{n} \frac{w_i}{h_1 \dots h_d} \left[ \prod_{j=1}^{d} K\left( \frac{x_j-x_{ij}}{h_j} \right) \right] \text{.}
|
||||
\end{equation}
|
||||
where the bandwidth is given as a vector $\bm{h}=(h_1, \dots, h_d)$.
|
||||
|
||||
Note that \eqref{eq:mvKDE} does not include all possible multivariate kernels, such as spherically symmetric kernels, which are based on rotation of a univariate kernel.
|
||||
In general a multivariate product and spherically symmetric kernel based on the same univariate kernel will differ.
|
||||
The only exception is the Gaussian kernel which is spherical symmetric and has independent marginals. % TODO scott cite?!
|
||||
In addition, only smoothing in the direction of the axes are possible.
|
||||
If smoothing in other directions is necessary, the computation needs to be done on a prerotated sample set and the estimate needs to be rotated back to fit the original coordinate system \cite{wand1994fast}.
|
||||
|
||||
For the multivariate BKDE, in addition to the kernel function the grid and the binning rules need to be extended to multivariate data.
|
||||
\todo{Reicht hier text oder müssen Formeln her?}
|
||||
|
||||
|
||||
In general multi-dimensional filters are multi-dimensional convolution operations.
|
||||
However, by utilizing the separability property of convolution a straightforward and a more efficient implementation can be found.
|
||||
Convolution is separable if the filter kernel is separable, i.e. it can be split into successive convolutions of several kernels.
|
||||
Likewise digital filters based on such kernels are called separable filters.
|
||||
They are easily applied to multi-dimensional signals, because the input signal can be filtered in each dimension separately by an one-dimensional filter.
|
||||
|
||||
The Gaussian filter is separable, because of $e^{x^2+y^2} = e^{x^2}\cdot e^{y^2}$.
|
||||
|
||||
|
||||
% KDE:
|
||||
%So far only the univariate case was considered.
|
||||
%This is due to the fact, that univariate kernel estimators can quite easily be extended to multivariate distributions.
|
||||
@@ -32,6 +85,10 @@
|
||||
%\end{equation}
|
||||
%where the bandwidth is given as a vector $\bm{h}=(h_1, \dots, h_d)$.
|
||||
|
||||
% Product kernel allows our method
|
||||
% Spherically symmetric kernel not supported, but Gaussian kernel == product & spehrically symmetric
|
||||
% smoothing not in the direction of the axes -> rotate data, kde, rotate back
|
||||
|
||||
%Multivariate Gauss-Kernel
|
||||
%\begin{equation}
|
||||
%K(u)=\frac{1}{(2\pi)^{d/2}} \expp{-\frac{1}{2} \bm{x}^T \bm{x}}
|
||||
@@ -54,7 +111,7 @@
|
||||
|
||||
|
||||
|
||||
|
||||
\subsection{Our method}
|
||||
The objective of our method is to allow a reliable recover of the most probable state from a time-sequential Monte Carlo sensor fusion system.
|
||||
Assuming a sample based representation, our method allows to estimate the density of the unknown distribution of the state space in a narrow time frame.
|
||||
Such systems are often used to obtain an estimation of the most probable state in near real time.
|
||||
|
||||
Reference in New Issue
Block a user