{
    "nbformat": 4,
    "nbformat_minor": 5,
    "metadata": {
        "kernelspec": {
            "display_name": "Python",
            "language": "python",
            "name": "python"
        },
        "language_info": {
            "name": "python"
        }
    },
    "cells": [
        {
            "id": "0c8baee2",
            "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": "a1fbe658",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "import numpy as np\nfrom scipy import stats\nx = [12, 2, 1, 12, 2]\ny = [1, 4, 7, 1, 0]\nres = stats.weightedtau(x, y)\nres.statistic",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "-0.56694968153682723"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "a0aaf056",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "res.pvalue",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "nan"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "75c79070",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "res = stats.weightedtau(x, y, additive=False)\nres.statistic",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "-0.62205716951801038"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "c6d88f20",
            "cell_type": "markdown",
            "source": "NaNs are considered the smallest possible score:\n",
            "metadata": {}
        },
        {
            "id": "c733554b",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "x = [12, 2, 1, 12, 2]\ny = [1, 4, 7, 1, np.nan]\nres = stats.weightedtau(x, y)\nres.statistic",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "-0.56694968153682723"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "c591800d",
            "cell_type": "markdown",
            "source": "This is exactly Kendall's tau:\n",
            "metadata": {}
        },
        {
            "id": "b0de50f2",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "x = [12, 2, 1, 12, 2]\ny = [1, 4, 7, 1, 0]\nres = stats.weightedtau(x, y, weigher=lambda x: 1)\nres.statistic",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "-0.47140452079103173"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "5ef87731",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "x = [12, 2, 1, 12, 2]\ny = [1, 4, 7, 1, 0]\nstats.weightedtau(x, y, rank=None)",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "SignificanceResult(statistic=-0.4157652301037516, pvalue=nan)"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "824522d5",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "stats.weightedtau(y, x, rank=None)",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "SignificanceResult(statistic=-0.7181341329699028, pvalue=nan)"
                    },
                    "execution_count": null
                }
            ]
        }
    ]
}