Skip to content

Commit

Permalink
v0.2.12
Browse files Browse the repository at this point in the history
  • Loading branch information
yh202109 committed Jun 29, 2024
1 parent 8f84fdc commit 2d68dae
Showing 1 changed file with 58 additions and 2 deletions.
60 changes: 58 additions & 2 deletions docs/statlab_corr_tau.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Notation

Let :math:`Y_{i1}` and :math:`Y_{i2}` be a pair of independent random variables corresponding to the :math:`i` th sample where :math:`i = 1, \ldots, n`.

.. list-table:: Count of Ratings
.. list-table:: Observed Value
:widths: 10 10 10
:header-rows: 1
:name: tbl_count1
Expand All @@ -63,7 +63,63 @@ The coefficient :math:`\tau` can be calculated as
.. math::
:label: eq_tau1
\tau = \frac{2}{n(n-1)} \left(2\sum_{i=1}^n \sum_{j < n} sign(Y_{i1}-Y_{j1})sign(Y_{i2}-Y_{j2}) \right).
\tau = \frac{2}{n(n-1)} \left( \sum_{i=1}^n \sum_{j < n} sign(Y_{i1}-Y_{j1})sign(Y_{i2}-Y_{j2}) \right).
*************
Example - Group-1
*************

.. list-table:: Kendall's :math:`\tau = 1.0`
:widths: 10 10 10
:header-rows: 1
:name: tbl_ex1

* -
- :math:`Y_{i1}`
- :math:`Y_{i2}`
* - **Sample:** 1
- 1
- 4
* - **Sample:** 2
- 3
- 6
* - **Sample:** 3
- 2
- 5

.. list-table:: Kendall's :math:`\tau = -1.0`
:widths: 10 10 10
:header-rows: 1
:name: tbl_ex1

* -
- :math:`Y_{i1}`
- :math:`Y_{i2}`
* - **Sample:** 1
- 1
- 6
* - **Sample:** 2
- 3
- 4
* - **Sample:** 3
- 2
- 5

*************
How-to
*************

To use ``scipy.stats``:

.. code:: python
from scipy.stats import kendalltau
y1 = [1,3,2]
y2 = [4,6,5]
tau, p_value = kendalltau(y1, y2)
print("Kendall's tau:", tau)
*************
Reference
Expand Down

0 comments on commit 2d68dae

Please sign in to comment.