{
    "nbformat": 4,
    "nbformat_minor": 5,
    "metadata": {
        "kernelspec": {
            "display_name": "Python",
            "language": "python",
            "name": "python"
        },
        "language_info": {
            "name": "python"
        }
    },
    "cells": [
        {
            "id": "5b782d7c",
            "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": "7679c598",
            "cell_type": "markdown",
            "source": "First we generate some random data from a Weibull distribution\nwith shape parameter 2.5:\n",
            "metadata": {}
        },
        {
            "id": "fa435775",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "import numpy as np\nfrom scipy import stats\nimport matplotlib.pyplot as plt\nrng = np.random.default_rng()\nc = 2.5\nx = stats.weibull_min.rvs(c, scale=4, size=2000, random_state=rng)",
            "outputs": []
        },
        {
            "id": "0353b6f0",
            "cell_type": "markdown",
            "source": "Generate the PPCC plot for this data with the Weibull distribution.\n",
            "metadata": {}
        },
        {
            "id": "67e86822",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "fig, ax = plt.subplots(figsize=(8, 6))\nres = stats.ppcc_plot(x, c/2, 2*c, dist='weibull_min', plot=ax)",
            "outputs": []
        },
        {
            "id": "2124c2d6",
            "cell_type": "markdown",
            "source": "We calculate the value where the shape should reach its maximum and a\nred line is drawn there. The line should coincide with the highest\npoint in the PPCC graph.\n",
            "metadata": {}
        },
        {
            "id": "e7eb1aa2",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "cmax = stats.ppcc_max(x, brack=(c/2, 2*c), dist='weibull_min')\nax.axvline(cmax, color='r')\nplt.show()",
            "outputs": []
        }
    ]
}