From 0b19bb128fa40f328169bc5b2d82a458c076eeff Mon Sep 17 00:00:00 2001 From: David Rotermund <54365609+davrot@users.noreply.github.com> Date: Fri, 5 Jan 2024 14:06:23 +0100 Subject: [PATCH] Update README.md Signed-off-by: David Rotermund <54365609+davrot@users.noreply.github.com> --- scipy/scipy.stats.fisher_exact/README.md | 42 ++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/scipy/scipy.stats.fisher_exact/README.md b/scipy/scipy.stats.fisher_exact/README.md index 89e42d6..12f1b64 100644 --- a/scipy/scipy.stats.fisher_exact/README.md +++ b/scipy/scipy.stats.fisher_exact/README.md @@ -22,7 +22,8 @@ scipy.stats.fisher_exact(table, alternative='two-sided') > > The null hypothesis is that the true odds ratio of the populations underlying the observations is one, and the observations were sampled from these populations under a condition: the marginals of the resulting table must equal those of the observed table. The statistic returned is the unconditional maximum likelihood estimate of the odds ratio, and the p-value is the probability under the null hypothesis of obtaining a table at least as extreme as the one that was actually observed. There are other possible choices of statistic and two-sided p-value definition associated with Fisher’s exact test; please see the Notes for more information. - +> Parameters: +> > **alternative** : {‘two-sided’, ‘less’, ‘greater’}, optional > Defines the alternative hypothesis. The following options are available (default is ‘two-sided’): > @@ -30,4 +31,41 @@ scipy.stats.fisher_exact(table, alternative='two-sided') > * ‘less’: the odds ratio of the underlying population is less than one > * ‘greater’: the odds ratio of the underlying population is greater than one -See the Notes for more details. +> Returns: +> +> **res** : SignificanceResult +> +> An object containing attributes: +> +> **statistic** : float +> +> This is the prior odds ratio, not a posterior estimate. +> +> **pvalue** : float +> +> The probability under the null hypothesis of obtaining a table at least as extreme as the one that was actually observed. + +The input table is [[a, b], [c, d]]. Where N_A = a + c for the elements in group A and N_B = b + d for the elements in group B. +[[N_A-c, N_B-d], [c, d]] + + +## [Example](https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.fisher_exact.html) + +||Group A|Group B| +|---|---|---| +|Yes| 7 | 17 | +|No| 15| 5| + +This translates in to the table: [[7, 17], [15, 5]] + + +```python +from scipy.stats import fisher_exact + +res = fisher_exact([[7, 17], [15, 5]], alternative="less") +print(res.statistic) # -> 0.13725490196078433 +print(res.pvalue) # -> 0.0028841933752349743 +``` + + +