{
    "nbformat": 4,
    "nbformat_minor": 5,
    "metadata": {
        "kernelspec": {
            "display_name": "Python",
            "language": "python",
            "name": "python"
        },
        "language_info": {
            "name": "python"
        }
    },
    "cells": [
        {
            "id": "59fb12bc",
            "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": "2b984b37",
            "cell_type": "markdown",
            "source": "`ndtri` is the percentile function of the standard normal distribution.\nThis means it returns the inverse of the cumulative density `ndtr`. First,\nlet us compute a cumulative density value.\n",
            "metadata": {}
        },
        {
            "id": "76bf586a",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "import numpy as np\nfrom scipy.special import ndtri, ndtr\ncdf_val = ndtr(2)\ncdf_val",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "0.9772498680518208"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "0f574f37",
            "cell_type": "markdown",
            "source": "Verify that `ndtri` yields the original value for `x` up to floating point\nerrors.\n",
            "metadata": {}
        },
        {
            "id": "18baec68",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "ndtri(cdf_val)",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "2.0000000000000004"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "9cbde4fb",
            "cell_type": "markdown",
            "source": "Plot the function. For that purpose, we provide a NumPy array as argument.\n",
            "metadata": {}
        },
        {
            "id": "aabb2fc3",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "import matplotlib.pyplot as plt\nx = np.linspace(0.01, 1, 200)\nfig, ax = plt.subplots()\nax.plot(x, ndtri(x))\nax.set_title(\"Standard normal percentile function\")\nplt.show()",
            "outputs": []
        }
    ]
}