{
    "nbformat": 4,
    "nbformat_minor": 5,
    "metadata": {
        "kernelspec": {
            "display_name": "Python",
            "language": "python",
            "name": "python"
        },
        "language_info": {
            "name": "python"
        }
    },
    "cells": [
        {
            "id": "5d00366d",
            "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": "9f6b7246",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "import numpy as np\nimport matplotlib.pyplot as plt\nfrom scipy.stats import multivariate_normal",
            "outputs": []
        },
        {
            "id": "c601ed85",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "x = np.linspace(0, 5, 10, endpoint=False)\ny = multivariate_normal.pdf(x, mean=2.5, cov=0.5); y",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "array([ 0.00108914,  0.01033349,  0.05946514,  0.20755375,  0.43939129,\n        0.56418958,  0.43939129,  0.20755375,  0.05946514,  0.01033349])"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "3e5b9b27",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "fig1 = plt.figure()\nax = fig1.add_subplot(111)\nax.plot(x, y)\nplt.show()",
            "outputs": []
        },
        {
            "id": "f50508b7",
            "cell_type": "markdown",
            "source": "Alternatively, the object may be called (as a function) to fix the mean\nand covariance parameters, returning a \"frozen\" multivariate normal\nrandom variable:\n",
            "metadata": {}
        },
        {
            "id": "5a53b0e2",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "rv = multivariate_normal(mean=None, cov=1, allow_singular=False)\n# Frozen object with the same methods but holding the given\n# mean and covariance fixed.",
            "outputs": []
        },
        {
            "id": "6612cbea",
            "cell_type": "markdown",
            "source": "The input quantiles can be any shape of array, as long as the last\naxis labels the components.  This allows us for instance to\ndisplay the frozen pdf for a non-isotropic random variable in 2D as\nfollows:\n",
            "metadata": {}
        },
        {
            "id": "5a9bd698",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "x, y = np.mgrid[-1:1:.01, -1:1:.01]\npos = np.dstack((x, y))\nrv = multivariate_normal([0.5, -0.2], [[2.0, 0.3], [0.3, 0.5]])\nfig2 = plt.figure()\nax2 = fig2.add_subplot(111)\nax2.contourf(x, y, rv.pdf(pos))",
            "outputs": []
        }
    ]
}