{
    "nbformat": 4,
    "nbformat_minor": 5,
    "metadata": {
        "kernelspec": {
            "display_name": "Python",
            "language": "python",
            "name": "python"
        },
        "language_info": {
            "name": "python"
        }
    },
    "cells": [
        {
            "id": "27c2f3be",
            "cell_type": "markdown",
            "source": "<div class='alert alert-warning'>\n\nSciPy's interactive examples with Jupyterlite are experimental and may not always work as expected. Execution of cells containing imports may result in large downloads (up to 60MB of content for the first import from SciPy). Load times when importing from SciPy may take roughly 10-20 seconds. If you notice any problems, feel free to open an [issue](https://github.com/scipy/scipy/issues/new/choose).\n\n</div>",
            "metadata": {}
        },
        {
            "id": "0ec58b93",
            "cell_type": "markdown",
            "source": "Autocorrelation of white noise is an impulse.\n",
            "metadata": {}
        },
        {
            "id": "74d54326",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "import numpy as np\nfrom scipy import signal\nrng = np.random.default_rng()\nsig = rng.standard_normal(1000)\nautocorr = signal.fftconvolve(sig, sig[::-1], mode='full')",
            "outputs": []
        },
        {
            "id": "7f695d14",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "import matplotlib.pyplot as plt\nfig, (ax_orig, ax_mag) = plt.subplots(2, 1)\nax_orig.plot(sig)\nax_orig.set_title('White noise')\nax_mag.plot(np.arange(-len(sig)+1,len(sig)), autocorr)\nax_mag.set_title('Autocorrelation')\nfig.tight_layout()\nfig.show()",
            "outputs": []
        },
        {
            "id": "6946cf87",
            "cell_type": "markdown",
            "source": "Gaussian blur implemented using FFT convolution.  Notice the dark borders\naround the image, due to the zero-padding beyond its boundaries.\nThe `convolve2d` function allows for other types of image boundaries,\nbut is far slower.\n",
            "metadata": {}
        },
        {
            "id": "67e4f001",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "from scipy import datasets\nface = datasets.face(gray=True)\nkernel = np.outer(signal.windows.gaussian(70, 8),\n                  signal.windows.gaussian(70, 8))\nblurred = signal.fftconvolve(face, kernel, mode='same')",
            "outputs": []
        },
        {
            "id": "2c9041b5",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "fig, (ax_orig, ax_kernel, ax_blurred) = plt.subplots(3, 1,\n                                                     figsize=(6, 15))\nax_orig.imshow(face, cmap='gray')\nax_orig.set_title('Original')\nax_orig.set_axis_off()\nax_kernel.imshow(kernel, cmap='gray')\nax_kernel.set_title('Gaussian kernel')\nax_kernel.set_axis_off()\nax_blurred.imshow(blurred, cmap='gray')\nax_blurred.set_title('Blurred')\nax_blurred.set_axis_off()\nfig.show()",
            "outputs": []
        }
    ]
}