{
    "nbformat": 4,
    "nbformat_minor": 5,
    "metadata": {
        "kernelspec": {
            "display_name": "Python",
            "language": "python",
            "name": "python"
        },
        "language_info": {
            "name": "python"
        }
    },
    "cells": [
        {
            "id": "0962238e",
            "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": "be65ff54",
            "cell_type": "markdown",
            "source": "Suppose we have a normally distributed random variable $X$:\n",
            "metadata": {}
        },
        {
            "id": "9111282f",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "import numpy as np\nfrom scipy import stats\nX = stats.Normal()",
            "outputs": []
        },
        {
            "id": "782713da",
            "cell_type": "markdown",
            "source": "We wish to have a lognormally distributed random variable $Y$,\na random variable whose natural logarithm is $X$.\nIf $X$ is to be the natural logarithm of $Y$, then we\nmust take $Y$ to be the natural exponential of $X$.\n",
            "metadata": {}
        },
        {
            "id": "504e27e6",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "Y = stats.exp(X)",
            "outputs": []
        },
        {
            "id": "89135ce4",
            "cell_type": "markdown",
            "source": "To demonstrate that ``X`` represents the logarithm of ``Y``,\nwe plot a normalized histogram of the logarithm of observations of\n``Y`` against the PDF underlying ``X``.\n",
            "metadata": {}
        },
        {
            "id": "fc9d04c1",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "import matplotlib.pyplot as plt\nrng = np.random.default_rng()\ny = Y.sample(shape=10000, rng=rng)\nax = plt.gca()\nax.hist(np.log(y), bins=50, density=True)\nX.plot(ax=ax)\nplt.legend(('PDF of `X`', 'histogram of `log(y)`'))\nplt.show()",
            "outputs": []
        }
    ]
}