Fast Fisher's Exact Test
Project description
Fisher's Exact Test
Simple, fast implementation of Fisher's exact test. For example, for the following table:
Having the property | Not having the property | |
---|---|---|
Selected | 12 | 5 |
Not selected | 29 | 2 |
Perhaps we are interested in whether there is any difference of property in selected vs. non-selected groups, then we can do the Fisher's exact test.
Installation
Within this folder :
git clone git://github.com/brentp/fishers_exact_test.git
pip install .
From PyPI :
pip install fisher
Or install the development version :
pip install git+git://github.com/brentp/fishers_exact_test.git
Usage
fisher.pvalue()
accepts 4 values corresponding to the 2-by-2
contingency table, returns an object with attributes for left_tail,
right_tail, and two_tail p-values :
>>> from fisher import pvalue
>>> mat = [[12, 5], [29, 2]]
>>> p = pvalue(12, 5, 29, 2)
>>> p.left_tail, p.right_tail, p.two_tail # doctest: +NORMALIZE_WHITESPACE, +ELLIPSIS
(0.04455473783507..., 0.994525206021..., 0.0802685520741...)
Benchmark
A simple benchmark that calls the Fisher's exact test 1000 times (in
scripts/rfisher.py
):
calling python fisher...
iterations/sec: 3000.62526381
calling rpy fisher...
iterations/sec: 289.225902364
calling R directly...
iterations/sec: 244.36542276
So the cython fisher is up to 10 times faster than rpy or R version.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file fisher-0.1.9.tar.gz
.
File metadata
- Download URL: fisher-0.1.9.tar.gz
- Upload date:
- Size: 145.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d378b3f7e488e2a679c6d0e5ea1bce17bc931c2bfe8ec8424ee47a74f251968d |
|
MD5 | 9549d2e9508ecff830c213566f7d6ff7 |
|
BLAKE2b-256 | bd8b951ab577d41d2bb7704e802173ea1de96918894d90636bfdf24477321f4f |