> For the complete documentation index, see [llms.txt](https://zavalab.gitbook.io/statschemebook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://zavalab.gitbook.io/statschemebook/chapter-6-statistical-data-analysis-and-learning/01-signal-processing/04-properties-of-convolution.md).

# Properties of Convolution

* FT facilitates analysis and implementation of convolution operations.
* Enabled by fundamental result known as *convolution theorem*:

  $$
  \mathcal{F}{f\*g}=\mathcal{F}{{f}}\cdot \mathcal{F}{{g}}.
  $$
* Convolution in freq domain obtained via products (instead of integrals).
* Pdf of sum of indep RVs $$X\_1$$ and $$X\_2$$ is convolution of pdfs $$f\_{X\_1}$$ and $$f\_{X\_2}$$.
* Specifically, pdf of $$Y=X\_1+X\_2$$ is $$f\_Y=f\_{X\_1}\*f\_{X\_2}$$.

## Example: Recursive Application of Convolution

{% hint style="danger" icon="flask" %}

* Consider indep RVs $$X\_1,X\_2,X\_3,X\_4\sim \mathcal{U}\_c(4,6)$$ with same pdf $$f(x)$$.
* Pdf of $$X\_1$$ is $$f$$, of $$X\_1+X\_2$$ is $$\varphi=f*f$$, of $$X\_1+X\_2+X\_3$$ is $$\varphi=f*(f*f)$$, and of $$X\_1+X\_2+X\_3+X\_4$$ is $$\varphi=f*(f\*(f\*f))$$.
* Result confirms central limit theorem (the sum of i.i.d. RVs approaches a Gaussian).
  {% endhint %}

<figure><img src="https://1753452229-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FakKE106umUCSWFtTnl31%2Fuploads%2Fgit-blob-cdb403a82243cbfc7a61560a58146d59e5ff612b%2Fch6_clt_convolutions.png?alt=media" alt="" width="350"><figcaption></figcaption></figure>

#### Python implementation

{% hint style="success" %}
Notebook [`ch6_clt_convolution.ipynb`](https://colab.research.google.com/github/vzavala/StatsBook/blob/master/Python/ch6_clt_convolution.ipynb) — open it in Colab and run the cells alongside this section.

MATLAB live script: [`ch6_clt_convolution.mlx`](https://github.com/vzavala/StatsBook/blob/master/Matlab-Live/ch6_clt_convolution.mlx)
{% endhint %}

The central limit theorem through convolutions (Victor Z and Ugochukwu Ikegwu, UW-Madison, 2024). For independent $$X\_i\sim\mathcal{U}(4,6)$$ with pdf $$f$$, the pdf of $$X\_1+X\_2$$ is $$\phi=f*f$$, of $$X\_1+X\_2+X\_3$$ is $$f*(f\*f)$$, and so on. We convolve numerically on a grid of step `dx` (`phi = np.convolve(phi, f) * dx`) and compare with the Gaussian that has the same mean and variance.

**Note:** This notebook reproduces Example 6.16 (Section 6.3.4) of *Statistics for Chemical Engineers*: repeated convolution of a pdf with itself.

```python
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import uniform, norm

dx = 0.01
x = np.arange(0, 6 + dx, dx)
f = uniform.pdf(x, loc=4, scale=2)

fig, axs = plt.subplots(2, 2, figsize=(10, 8))
phi = f.copy()
for k, ax in enumerate(axs.ravel(), start=1):
    if k > 1:
        phi = np.convolve(phi, f) * dx               # pdf of X_1 + ... + X_k
    xk = np.arange(len(phi)) * dx
    ax.plot(xk, phi, 'k', linewidth=1.5, label='convolution')
    if k > 1:
        ax.plot(xk, norm.pdf(xk, 5 * k, np.sqrt(k * 4 / 12)), 'k:', linewidth=2, label='Gaussian')
    ax.set_xlim(4 * k - 1, 6 * k + 1)
    ax.set_title(f'sum of {k} uniform RVs')
    ax.set_xlabel('$x$'); ax.set_ylabel(r'$\phi(x)$')
    ax.grid(True)
axs[0, 1].legend()
plt.tight_layout()
plt.show()
```

<figure><img src="https://1753452229-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FakKE106umUCSWFtTnl31%2Fuploads%2Fgit-blob-422da98be993c00b5152d6b501ef909c7adc08b5%2Fch6_clt_convolution-03-0.png?alt=media" alt="" width="520"><figcaption></figcaption></figure>

**Note:** As in the book, repeated convolution progressively smooths the pdf toward a Gaussian: this is the central limit theorem.
