{
    "nbformat": 4,
    "nbformat_minor": 5,
    "metadata": {
        "kernelspec": {
            "display_name": "Python",
            "language": "python",
            "name": "python"
        },
        "language_info": {
            "name": "python"
        }
    },
    "cells": [
        {
            "id": "329495e1",
            "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": "f2e6a445",
            "cell_type": "markdown",
            "source": "Design a digital lowpass filter such that the passband is within 3 dB up\nto 0.2*(fs/2), while rejecting at least -40 dB above 0.3*(fs/2). Plot its\nfrequency response, showing the passband and stopband constraints in gray.\n",
            "metadata": {}
        },
        {
            "id": "ebf77546",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "from scipy import signal\nimport matplotlib.pyplot as plt\nimport numpy as np",
            "outputs": []
        },
        {
            "id": "32d87381",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "N, Wn = signal.cheb1ord(0.2, 0.3, 3, 40)\nb, a = signal.cheby1(N, 3, Wn, 'low')\nw, h = signal.freqz(b, a)\nplt.semilogx(w / np.pi, 20 * np.log10(abs(h)))\nplt.title('Chebyshev I lowpass filter fit to constraints')\nplt.xlabel('Normalized frequency')\nplt.ylabel('Amplitude [dB]')\nplt.grid(which='both', axis='both')\nplt.fill([.01, 0.2, 0.2, .01], [-3, -3, -99, -99], '0.9', lw=0) # stop\nplt.fill([0.3, 0.3,   2,   2], [ 9, -40, -40,  9], '0.9', lw=0) # pass\nplt.axis([0.08, 1, -60, 3])\nplt.show()",
            "outputs": []
        }
    ]
}