{
    "nbformat": 4,
    "nbformat_minor": 5,
    "metadata": {
        "kernelspec": {
            "display_name": "Python",
            "language": "python",
            "name": "python"
        },
        "language_info": {
            "name": "python"
        }
    },
    "cells": [
        {
            "id": "c6c804d1",
            "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": "d47e58af",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "from scipy.stats import binomtest",
            "outputs": []
        },
        {
            "id": "d2dce1d3",
            "cell_type": "markdown",
            "source": "A car manufacturer claims that no more than 10% of their cars are unsafe.\n15 cars are inspected for safety, 3 were found to be unsafe. Test the\nmanufacturer's claim:\n",
            "metadata": {}
        },
        {
            "id": "85aac3f7",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "result = binomtest(3, n=15, p=0.1, alternative='greater')\nresult.pvalue",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "0.18406106910639114"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "537f4ea6",
            "cell_type": "markdown",
            "source": "The null hypothesis cannot be rejected at the 5% level of significance\nbecause the returned p-value is greater than the critical value of 5%.\n\nThe test statistic is equal to the estimated proportion, which is simply\n``3/15``:\n",
            "metadata": {}
        },
        {
            "id": "0ffb4c3c",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "result.statistic",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "0.2"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "c94f56ff",
            "cell_type": "markdown",
            "source": "We can use the `proportion_ci()` method of the result to compute the\nconfidence interval of the estimate:\n",
            "metadata": {}
        },
        {
            "id": "5070ffb1",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "result.proportion_ci(confidence_level=0.95)",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "ConfidenceInterval(low=0.05684686759024681, high=1.0)"
                    },
                    "execution_count": null
                }
            ]
        }
    ]
}