April 26, 2023

Correlation and convolution

In reciprocal space, the signal recorded by the detector at position \(\mathbf{q}\) is characterized by the electric field amplitude \(E(\mathbf{q})\), but the experimentally accessible quantity is its modulus squared, the intensity \(I(\mathbf{q}) = |E(\mathbf{q})|^2\). In real space, the structure is described by the density function \(\rho(\mathbf{r})\) but, as we will see in the next post, it is useful to define two new types of functions "of the type of the square", but where the two instances of \(\rho\) are evaluated in different space points.

The first such combination is the convolution:
\begin{equation}
f(\mathbf{r}) * g(\mathbf{r}) \triangleq \int_{\mathcal{V}} f(\mathbf{r}')\overline{g(\mathbf{r}-\mathbf{r}')} {\textrm d} \mathbf{r}'
\label{eq:conv}
\end{equation}
where the overbar \(\overline{\cdot}\) denotes the complex conjugation.

The second one is the correlation:
\begin{equation} \Gamma_{fg}(\mathbf{r}) \triangleq \int_{\mathcal{V}} f(\mathbf{r}')\overline{g(\mathbf{r}'-\mathbf{r})} {\textrm d} \mathbf{r}' \label{eq:corr} \end{equation} There is an obvious similarity between \eqref{eq:conv} and \eqref{eq:corr}, which can be formalized by noting that:\begin{equation}
\Gamma _{fg}(\mathbf{r}) = f(\mathbf{r}) * g(-\mathbf{r}) \label{eq:convcorr}
\end{equation}and the two operations are identical if \(g\) is symmetric with respect to the origin (\(g(\mathbf{r}) = g(-\mathbf{r})\)). Nevertheless, if this symmetry does not hold the results can be quite different, as we will see in the following (one-dimensional) example.

Let us consider:
\begin{equation}f(x) = g(x) = \left\lbrace \begin{array}{cc} \dfrac{1}{\lambda} \exp \left (-\dfrac{x}{\lambda} \right )& x \geq 0 \\ 0 & \text{ otherwise.} \\ \end{array} \right.\end{equation}
For the convolution \(h(x) = f(x) * g(x) = \int_{-\infty}^{\infty} f(x')g(x-x') {\textrm d} x'\), the integration variable \(x'\) appears in the argument of \(g\) with a minus sign. The second factor in the integrand is thus the same as the first, but reversed with respect to the origin and shifted to the right by the amount \(x\). We dropped the complex conjugation since the functions are real.

Figure 1: The two functions to be convolved \(f\) and \(g\) and their product \(h\) for a given shift \(x = \lambda\).

Figure 1 shows functions \(f(x')\) (in red) and \(g(x-x')\) (in blue) for a shift \(x = \lambda\). Their product is shown as purple line, and the area under this curve is precisely the value of their convolution for this particular shift \(h(x)\).
It is easy to show that:
\begin{equation}h(x) = \left\lbrace \begin{array}{cc} \dfrac{x}{\lambda^2} \exp \left (-\dfrac{x}{\lambda} \right )& x \geq 0 \\ 0 & \text{ otherwise.} \\ \end{array} \right. \end{equation}
with a maximum \(h(x_{\text{max}}) = (\lambda \text{e})^{-1}\) at \(x_{\text{max}} = \lambda\). Figure 2 shows how this function is built up. 

 

Figure 2: Convolution of two decaying exponentials (purple line) and the way it is built up from the superposition of the two factors. 

If \(x<0\) the supports of these two terms do not overlap, and thus \(h(x) = 0\). They start overlapping for \(x = 0\) and their product increases rapidly with increasing \(x\) until \(x_{\text{max}}\), after which it decreases as the two maxima shift away from each other. As for the convolution factors \(f\) and \(g\), the result \(h(x) \geq 0\), its support is the range of positive \(x\) and its integral is 1.

The autocorrelation, on the other hand, is obviously symmetric with respect to the origin: shifting one instance of \(f\) to the left or to the right by the same amount yields the same result, which is once again positive and normalized to 1:
\begin{equation}\Gamma_{ff} = \int_{-\infty}^{\infty} f(x')g(x'-x) {\textrm d} x'= \dfrac{1}{2 \lambda} \exp \left (-\dfrac{|x|}{\lambda} \right )\end{equation}
As shown in Figure 3, the product \(f(x')g(x'-x)\) decays twice faster than the individual factors, and its amplitude decreases rapidly with the (absolute value of) the shift.

Figure 3: The two functions to be correlated \(f\) and \(g\) and their product \(h\) for a given shift \(x = -\lambda\).

No comments:

Post a Comment