{
    "nbformat": 4,
    "nbformat_minor": 5,
    "metadata": {
        "kernelspec": {
            "display_name": "Python",
            "language": "python",
            "name": "python"
        },
        "language_info": {
            "name": "python"
        }
    },
    "cells": [
        {
            "id": "423cf6d9",
            "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": "cbddb1aa",
            "cell_type": "markdown",
            "source": "Suppose that a gardener wishes to test the number of dodder (weed) seeds\nin a sack of clover seeds that they buy from a seed company. It has\npreviously been established that the number of dodder seeds in clover\nfollows the Poisson distribution.\n\nA 100 gram sample is drawn from the sack before being shipped to the\ngardener. The sample is analyzed, and it is found to contain no dodder\nseeds; that is, `k1` is 0. However, upon arrival, the gardener draws\nanother 100 gram sample from the sack. This time, three dodder seeds are\nfound in the sample; that is, `k2` is 3. The gardener would like to\nknow if the difference is significant and not due to chance. The\nnull hypothesis is that the difference between the two samples is merely\ndue to chance, or that $\\lambda_1 - \\lambda_2 = \\mathtt{diff}$\nwhere $\\mathtt{diff} = 0$. The alternative hypothesis is that the\ndifference is not due to chance, or $\\lambda_1 - \\lambda_2 \\ne 0$.\nThe gardener selects a significance level of 5% to reject the null\nhypothesis in favor of the alternative [2].\n",
            "metadata": {}
        },
        {
            "id": "bb3dd5f4",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "import scipy.stats as stats\nres = stats.poisson_means_test(0, 100, 3, 100)\nres.statistic, res.pvalue",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "(-1.7320508075688772, 0.08837900929018157)"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "39f97fab",
            "cell_type": "markdown",
            "source": "The p-value is .088, indicating a near 9% chance of observing a value of\nthe test statistic under the null hypothesis. This exceeds 5%, so the\ngardener does not reject the null hypothesis as the difference cannot be\nregarded as significant at this level.",
            "metadata": {}
        }
    ]
}