{
    "nbformat": 4,
    "nbformat_minor": 5,
    "metadata": {
        "kernelspec": {
            "display_name": "Python",
            "language": "python",
            "name": "python"
        },
        "language_info": {
            "name": "python"
        }
    },
    "cells": [
        {
            "id": "fef71845",
            "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": "1a0701e3",
            "cell_type": "markdown",
            "source": "The following code creates a lowpass Butterworth filter. Then it\napplies that filter to an array whose values are all 1.0; the\noutput is also all 1.0, as expected for a lowpass filter.  If the\n`zi` argument of `lfilter` had not been given, the output would have\nshown the transient signal.\n",
            "metadata": {}
        },
        {
            "id": "2a4164d1",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "from numpy import array, ones\nfrom scipy.signal import lfilter, lfilter_zi, butter\nb, a = butter(5, 0.25)\nzi = lfilter_zi(b, a)\ny, zo = lfilter(b, a, ones(10), zi=zi)\ny",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "array([1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.])"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "d13ef031",
            "cell_type": "markdown",
            "source": "Another example:\n",
            "metadata": {}
        },
        {
            "id": "465faab9",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "x = array([0.5, 0.5, 0.5, 0.0, 0.0, 0.0, 0.0])\ny, zf = lfilter(b, a, x, zi=zi*x[0])\ny",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "array([ 0.5       ,  0.5       ,  0.5       ,  0.49836039,  0.48610528,\n    0.44399389,  0.35505241])"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "b53639bb",
            "cell_type": "markdown",
            "source": "Note that the `zi` argument to `lfilter` was computed using\n`lfilter_zi` and scaled by ``x[0]``.  Then the output `y` has no\ntransient until the input drops from 0.5 to 0.0.",
            "metadata": {}
        }
    ]
}