Discrete convolution is a fundamental mathematical operation used across many fields, including signal processing, image analysis, and, crucially, probabilistic state estimation like the Bayes Filter. It provides a formal, structured way to combine two sequences of numbers (or functions) to produce a third sequence that represents how the shape of one sequence is modified by the other.
Given two discrete functions (or sequences) $f$ and $g$, their discrete convolution, denoted by $(f * g)$, is defined as:
$$(f * g)[n] = \sum_{k} f[k] \cdot g[n - k]$$
Where:
Note: The convolution is commutative, i.e. $f * g = g * f$
In the context of your localization problem, discrete convolution has a specific probabilistic meaning:
This example uses a discrete signal $f$ and a motion kernel $g$.
[0, 0, 0, 1.0, 0, 0] (A single point/robot at index 3)[0.0, 0.2, 0.8]: stand still probability is 0.2 and moving right with probability 0.8.Flip
The kernel $g$ is reversed around its center point:
[0.0, 0.2, 0.8][0.8, 0.2, 0.0]Shift, Multiply and Sum We slide the flipped kernel $g_{rev}$ across signal $f$. The output at index $n$ is the sum of products where they overlap.
At position $n = 2$:
Index: 0 1 2 3 4 5
f_t[k]: 0 0 0 1.0 0 0
|
g_rev[2-k]: [0.8, 0.2, 0.0]
|
Calculation: 1.0 * 0.0 = 0.0
Output f_tp1[3]: 0.0
At position $n = 3$:
Index: 0 1 2 3 4 5
f[k]: 0 0 0 1.0 0 0
|
g_rev[3-k]: [0.8, 0.2, 0.0]
|
Calculation: 1.0 * 0.2 = 0.2
Output f_tp1[3]: 0.2
At position $n = 4$
Index: 0 1 2 3 4 5
f[k]: 0 0 0 1.0 0 0
|
g_rev[4-k]: [0.8, 0.2, 0.0]
|
Calculation: 1.0 * 0.8 = 0.8
Output f_tp1[4]: 0.8
import numpy as np
f = np.array([0., 0., 0., 1., 0., 0., 0., 0.])
g = np.array([0., 0.2, 0.8])
np.convolve(f, g, mode="same")
$f$ is a distribution:
f = np.array([0., 0., 0., 0.1, 0.7, 0.2, 0., 0.])
g = np.array([0., 0.2, 0.8])
np.convolve(f, g, mode="same")
fm1 = np.array([0., 0., 0., 0.1, 0.0, 0.0, 0., 0.])
f0 = np.array([0., 0., 0., 0.0, 0.7, 0.0, 0., 0.])
f1 = np.array([0., 0., 0., 0.0, 0.0, 0.2, 0., 0.])
np.convolve(fm1, g, mode="same"), np.convolve(f0, g, mode="same"), np.convolve(f1, g, mode="same")
np.convolve(fm1, g, mode="same") + np.convolve(f0, g, mode="same") + np.convolve(f1, g, mode="same")
In practice, the physical meaning of convolution is often one of: