{
    "nbformat": 4,
    "nbformat_minor": 5,
    "metadata": {
        "kernelspec": {
            "display_name": "Python",
            "language": "python",
            "name": "python"
        },
        "language_info": {
            "name": "python"
        }
    },
    "cells": [
        {
            "id": "5f40a28e",
            "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": "4abb6207",
            "cell_type": "markdown",
            "source": "In Fisher's definition, the kurtosis of the normal distribution is zero.\nIn the following example, the kurtosis is close to zero, because it was\ncalculated from the dataset, not from the continuous distribution.\n",
            "metadata": {}
        },
        {
            "id": "b217452d",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "import numpy as np\nfrom scipy.stats import norm, kurtosis\ndata = norm.rvs(size=1000, random_state=3)\nkurtosis(data)",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "-0.06928694200380558"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "30f5c384",
            "cell_type": "markdown",
            "source": "The distribution with a higher kurtosis has a heavier tail.\nThe zero valued kurtosis of the normal distribution in Fisher's definition\ncan serve as a reference point.\n",
            "metadata": {}
        },
        {
            "id": "0b4382db",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "import matplotlib.pyplot as plt\nimport scipy.stats as stats\nfrom scipy.stats import kurtosis",
            "outputs": []
        },
        {
            "id": "7d046a7a",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "x = np.linspace(-5, 5, 100)\nax = plt.subplot()\ndistnames = ['laplace', 'norm', 'uniform']",
            "outputs": []
        },
        {
            "id": "546afc2a",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "for distname in distnames:\n    if distname == 'uniform':\n        dist = getattr(stats, distname)(loc=-2, scale=4)\n    else:\n        dist = getattr(stats, distname)\n    data = dist.rvs(size=1000)\n    kur = kurtosis(data, fisher=True)\n    y = dist.pdf(x)\n    ax.plot(x, y, label=\"{}, {}\".format(distname, round(kur, 3)))\n    ax.legend()",
            "outputs": []
        },
        {
            "id": "335697c9",
            "cell_type": "markdown",
            "source": "The Laplace distribution has a heavier tail than the normal distribution.\nThe uniform distribution (which has negative kurtosis) has the thinnest\ntail.\n",
            "metadata": {}
        }
    ]
}