{
    "nbformat": 4,
    "nbformat_minor": 5,
    "metadata": {
        "kernelspec": {
            "display_name": "Python",
            "language": "python",
            "name": "python"
        },
        "language_info": {
            "name": "python"
        }
    },
    "cells": [
        {
            "id": "b385597c",
            "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": "00d140ce",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "import numpy as np\nfrom scipy.stats.contingency import margins",
            "outputs": []
        },
        {
            "id": "ef5031db",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "a = np.arange(12).reshape(2, 6)\na",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "array([[ 0,  1,  2,  3,  4,  5],\n       [ 6,  7,  8,  9, 10, 11]])"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "07164f36",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "m0, m1 = margins(a)\nm0",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "array([[15],\n       [51]])"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "ee1a468c",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "m1",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "array([[ 6,  8, 10, 12, 14, 16]])"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "0410eba9",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "b = np.arange(24).reshape(2,3,4)\nm0, m1, m2 = margins(b)\nm0",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "array([[[ 66]],\n       [[210]]])"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "a49b2ddf",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "m1",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "array([[[ 60],\n        [ 92],\n        [124]]])"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "f47735ac",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "m2",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "array([[[60, 66, 72, 78]]])"
                    },
                    "execution_count": null
                }
            ]
        }
    ]
}