Skip to main content

Fast Fisher's Exact Test

Project description

Fisher's Exact Test

Package image

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fisher-0.1.14.tar.gz (22.4 kB view hashes)

Uploaded Source

Built Distributions

fisher-0.1.14-cp311-cp311-win_amd64.whl (81.4 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

fisher-0.1.14-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (517.2 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

fisher-0.1.14-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (511.0 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

fisher-0.1.14-cp311-cp311-macosx_11_0_arm64.whl (85.6 kB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

fisher-0.1.14-cp311-cp311-macosx_10_9_x86_64.whl (92.4 kB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

fisher-0.1.14-cp310-cp310-win_amd64.whl (81.3 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

fisher-0.1.14-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (478.0 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

fisher-0.1.14-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (472.0 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

fisher-0.1.14-cp310-cp310-macosx_11_0_arm64.whl (85.4 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

fisher-0.1.14-cp310-cp310-macosx_10_9_x86_64.whl (92.2 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

fisher-0.1.14-cp39-cp39-win_amd64.whl (81.9 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

fisher-0.1.14-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (480.6 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

fisher-0.1.14-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (474.4 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

fisher-0.1.14-cp39-cp39-macosx_11_0_arm64.whl (85.9 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

fisher-0.1.14-cp39-cp39-macosx_10_9_x86_64.whl (92.8 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

fisher-0.1.14-cp38-cp38-win_amd64.whl (81.9 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

fisher-0.1.14-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (486.8 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

fisher-0.1.14-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (479.6 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

fisher-0.1.14-cp38-cp38-macosx_11_0_arm64.whl (85.3 kB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

fisher-0.1.14-cp38-cp38-macosx_10_9_x86_64.whl (92.2 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

fisher-0.1.14-cp37-cp37m-win_amd64.whl (81.0 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

fisher-0.1.14-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (453.4 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

fisher-0.1.14-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (445.1 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ ARM64

fisher-0.1.14-cp37-cp37m-macosx_10_9_x86_64.whl (92.2 kB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page