372 Convolution

An operation on two functions that is used to combine their values at different shifts and describe the output of a linear system whose response shifts with its input.

Discrete convolution. At each output position, convolution reverses and shifts the second sequence, multiplies its entries by the corresponding entries of the first sequence, and adds the products. This principle is used to compute the response at each shift.

The discrete convolution sum is

\[ y[n]=(x*h)[n]=\sum_{k\in\mathbb Z}x[k]h[n-k] \]

where

  • \(x\) and \(h\) are sequences indexed by the integers \(\mathbb Z\).
  • \(*\) denotes convolution and \(y\) is the resulting sequence.
  • \(n\) is the output index and \(k\) is the summation index.
  • \(h[n-k]\) is the entry of the reversed and shifted second sequence paired with \(x[k]\).

Full finite convolution. Extend both sequences by zero beyond their given indices. If their lengths are \(m\) and \(r\) and they start at index zero, the full output has \(m+r-1\) positions. This principle is used to keep all shifts at which the finite sequences can overlap.

Toeplitz matrix representation. With the second sequence fixed, convolution is a linear map of the first. Its matrix is Toeplitz, meaning the entries are constant along each diagonal. This principle is used to calculate convolution by matrix multiplication.

The matrix representation is

\[ \mathbf y=T_h\mathbf x,\qquad (T_h)_{n,k}=h[n-k] \]

where

  • \(\mathbf x\) is the column vector of the \(m\) given input samples.
  • \(\mathbf y\) is the column vector of the \(m+r-1\) output samples.
  • \(T_h\) is the matrix formed from the zero-extended sequence \(h\).
  • \(n\) runs from \(0\) to \(m+r-2\) and \(k\) runs from \(0\) to \(m-1\).

Cross-correlation. For real sequences, cross-correlation compares the input with a shifted copy of the second sequence in its original order. This principle is used to measure how strongly the sequences match at each shift.

The discrete cross-correlation is

\[ c[n]=\sum_{k\in\mathbb Z}x[n+k]h[k] \]

where

  • \(c[n]\) is the cross-correlation at shift \(n\).

Continuous convolution. For functions on the real line, an integral combines the products of one function with a reversed and shifted copy of the other. This principle is used to compute the response of a continuous-time system.

The continuous convolution integral is

\[ (x*h)(t)=\int_{-\infty}^{\infty}x(\tau)h(t-\tau)\,d\tau \]

where

  • \(x\) and \(h\) are functions on the real line for which the integral exists.
  • \(t\) is the output argument and \(\tau\) is the integration variable.

372.1 Elementary Example

372.1.1 Simple

Convolve the input values one and two with a sequence of two ones. At the middle shift both input values contribute. At each end only one contributes.

The full convolution is

\[ x=(1,2),\qquad h=(1,1),\qquad y=(1,1+2,2)=(1,3,2) \]

where

  • \(x\) and \(h\) are zero outside their two listed positions.
  • \(y\) lists the output in increasing index order.

372.1.2 General

Three input values are multiplied by a Toeplitz matrix. Each column contains the second sequence shifted down one position from the previous column.

The matrix calculation is

\[ \mathbf y= \begin{bmatrix} 2&0&0\\ -1&2&0\\ 1&-1&2\\ 0&1&-1\\ 0&0&1 \end{bmatrix} \begin{bmatrix}1\\3\\2\end{bmatrix} =\begin{bmatrix}2\\5\\2\\1\\2\end{bmatrix} \]

where

  • The matrix is \(T_h\) for \(h=(2,-1,1)\).
  • The first column vector is \(\mathbf x\) and the last is the full convolution \(\mathbf y\).

372.2 References

  1. Oppenheim, A. V., Willsky, A. S., and Nawab, S. H. Signals and Systems. Second edition. Prentice Hall. §2.1–2.2. Discrete convolution sum and continuous convolution integral.
  2. Murphy, K. P. Probabilistic Machine Learning: An Introduction. MIT Press, 2022. §14.2.1. Discrete convolution, cross-correlation, and convolution as a matrix operation. Both numerical examples specialize those constructions.