Skip to main content

Accurate and efficient binomial, Hardy-Weinberg equilibrium, and Fisher's exact tests.

Project description

exact_tests

This package provides binomial, Hardy-Weinberg equilibrium, and Fisher's exact test (2x2 and 2x3 so far) functions, along with binomial and hypergeometric distribution functions with scipy- and R-style interfaces. The functions are accurate and efficient:

  • High-precision and interval arithmetic are used to ensure likelihood near-ties are correctly resolved. Log-(mid)p-values are available when you don't want to just round tiny p-values down to zero.

  • It's relatively expensive to compute a contingency table's likelihood from scratch, but it's cheap when the likelihood of an adjacent contingency table is known. And it's even cheaper to skip a likelihood calculation when the value must be too small to matter. These functions take advantage of the latter possibilities.

Build instructions

PyPI:

pip install 'pip>=20.3'
pip install exact_tests

GitHub:

pip install 'pip>=20.3'
pip install -e 'git+https://github.com/chrchang/stats.git#egg=exact_tests&subdirectory=Python'

Or install from a cloned copy:

# clone repo
git clone https://github.com/chrchang/stats
# go to python folder
cd stats/Python
# install the package
pip install -e .

You can test the package with pytest.

Example usage:
import exact_tests

exact_tests.binom_test(3, n=15, p=0.1, alternative="greater")
exact_tests.binom_test(2, 29, 0.1)
exact_tests.binom_test(2, 29, "0.1")
exact_tests.binom_test(2, 29, "0.1", midp=True)
exact_tests.binom_test(100, 10000, "0.000001", logp=True)
exact_tests.fisher_test([[4, 0], [0, 4]], alternative="greater", midp=True)
exact_tests.fisher_test([[10000, 20000], [30000, 40000], [50000, 60000]], logp=True)

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

exact_tests-0.5.1.tar.gz (231.4 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

exact_tests-0.5.1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (1.2 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

exact_tests-0.5.1-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

exact_tests-0.5.1-cp314-cp314-macosx_10_15_universal2.whl (483.5 kB view details)

Uploaded CPython 3.14macOS 10.15+ universal2 (ARM64, x86-64)

exact_tests-0.5.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (1.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

exact_tests-0.5.1-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

exact_tests-0.5.1-cp313-cp313-macosx_10_13_universal2.whl (479.7 kB view details)

Uploaded CPython 3.13macOS 10.13+ universal2 (ARM64, x86-64)

exact_tests-0.5.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (1.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

exact_tests-0.5.1-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

exact_tests-0.5.1-cp312-cp312-macosx_10_13_universal2.whl (481.0 kB view details)

Uploaded CPython 3.12macOS 10.13+ universal2 (ARM64, x86-64)

exact_tests-0.5.1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (1.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

exact_tests-0.5.1-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

exact_tests-0.5.1-cp311-cp311-macosx_10_9_universal2.whl (478.9 kB view details)

Uploaded CPython 3.11macOS 10.9+ universal2 (ARM64, x86-64)

exact_tests-0.5.1-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (1.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

exact_tests-0.5.1-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

exact_tests-0.5.1-cp310-cp310-macosx_10_9_universal2.whl (479.3 kB view details)

Uploaded CPython 3.10macOS 10.9+ universal2 (ARM64, x86-64)

File details

Details for the file exact_tests-0.5.1.tar.gz.

File metadata

  • Download URL: exact_tests-0.5.1.tar.gz
  • Upload date:
  • Size: 231.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for exact_tests-0.5.1.tar.gz
Algorithm Hash digest
SHA256 a70e147750c68f63bbd9854f1fb21cad26e04ff0b5cf6faf675714c899915544
MD5 4f1658d4c52d8833c82396eb9e5bb8d9
BLAKE2b-256 cf237c76dd8b627b6a9ea302e0b40a12648fa03e777f7c17a76721ae1b912f6d

See more details on using hashes here.

Provenance

The following attestation bundles were made for exact_tests-0.5.1.tar.gz:

Publisher: release.yaml on chrchang/stats

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file exact_tests-0.5.1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for exact_tests-0.5.1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 42d6dae2c18005e7a68649b97508fcc1233b90f935198f910ee6e7f8de965592
MD5 4a8ffc0b409ccdacb2940b0f5ecabf34
BLAKE2b-256 9ae8b5ba2ed210a8d723a8b54e42b6afbff762cc06dc9bfd00da0e9b75e0b96c

See more details on using hashes here.

Provenance

The following attestation bundles were made for exact_tests-0.5.1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl:

Publisher: release.yaml on chrchang/stats

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file exact_tests-0.5.1-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for exact_tests-0.5.1-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 31a1316961e4e6295661e0ef540077f7c75b331a00a4a892b5c742df1e040be1
MD5 9fdb5845a362af563532222c9fba4e01
BLAKE2b-256 c50dd9e1f4886ab3e37317baf50f2e0f2520c19b68928fba5f960ff3d53dac3c

See more details on using hashes here.

Provenance

The following attestation bundles were made for exact_tests-0.5.1-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl:

Publisher: release.yaml on chrchang/stats

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file exact_tests-0.5.1-cp314-cp314-macosx_10_15_universal2.whl.

File metadata

File hashes

Hashes for exact_tests-0.5.1-cp314-cp314-macosx_10_15_universal2.whl
Algorithm Hash digest
SHA256 9fde97ac8ca787356535e125513f79561da68077b63e3f5088417d8a93a411a2
MD5 45ea170c70f468bc89aa819d43190620
BLAKE2b-256 c261bf676d9eb0bb1a20613a907008b373eaa01821cd7db1c69696717396521b

See more details on using hashes here.

Provenance

The following attestation bundles were made for exact_tests-0.5.1-cp314-cp314-macosx_10_15_universal2.whl:

Publisher: release.yaml on chrchang/stats

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file exact_tests-0.5.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for exact_tests-0.5.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e11c32631a4ab6719d694b6621ec22d314224abd172cbe48c0599e5fac812b23
MD5 7622025e7b7826e1c2d33465e7178d06
BLAKE2b-256 7157cc6a7b6b3bc24480f18ba6994c68f6dac85d1108b95b56cc74ceb49012cf

See more details on using hashes here.

Provenance

The following attestation bundles were made for exact_tests-0.5.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl:

Publisher: release.yaml on chrchang/stats

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file exact_tests-0.5.1-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for exact_tests-0.5.1-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 0110d8ee20d345db072198c3a1ebc51c2f3d6bc85375d3af2f3cc4e0a8e9bede
MD5 15d55c0e4a80441c100aa1528b9edc93
BLAKE2b-256 b4e455ee0ba2824639e0009d850038d50953b98978379537e789a3cdaa1cd3f3

See more details on using hashes here.

Provenance

The following attestation bundles were made for exact_tests-0.5.1-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl:

Publisher: release.yaml on chrchang/stats

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file exact_tests-0.5.1-cp313-cp313-macosx_10_13_universal2.whl.

File metadata

File hashes

Hashes for exact_tests-0.5.1-cp313-cp313-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 b293463bf8eb594d8e11784f4e8cf569aaa160ada8595baab93bc646e2f0b07c
MD5 918fbd1788b52bdc65adf91a88a17787
BLAKE2b-256 373cb69dee854b49ccd32fd511d3787a634c85563f54590f60df85f0cacba898

See more details on using hashes here.

Provenance

The following attestation bundles were made for exact_tests-0.5.1-cp313-cp313-macosx_10_13_universal2.whl:

Publisher: release.yaml on chrchang/stats

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file exact_tests-0.5.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for exact_tests-0.5.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 822215c6cd49988a009145aefa5e5de8c6375c0f53699d5fdc54ce96dfcd03d4
MD5 12f940ed6271d4b4ed2318adfe9c209b
BLAKE2b-256 52c63e8ab0f360352534aa928407636dddd60e1692e616a5df30d58ddb7dda07

See more details on using hashes here.

Provenance

The following attestation bundles were made for exact_tests-0.5.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl:

Publisher: release.yaml on chrchang/stats

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file exact_tests-0.5.1-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for exact_tests-0.5.1-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 4b43eadc61bbc8480216afae74ca5d64ebc4f8c01a683fa8d59d5651bf98dda3
MD5 85495ba55ea9e5118b0e8f31de96c9c2
BLAKE2b-256 98441d6272feac35dc46c1bbb4fe389dda46fe91418b4e205bd9e2b55da64d24

See more details on using hashes here.

Provenance

The following attestation bundles were made for exact_tests-0.5.1-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl:

Publisher: release.yaml on chrchang/stats

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file exact_tests-0.5.1-cp312-cp312-macosx_10_13_universal2.whl.

File metadata

File hashes

Hashes for exact_tests-0.5.1-cp312-cp312-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 fb941f619e5e6654234b651c367415cc44783aacd29a1f52bd19d3850a325816
MD5 9265c0944c31a8c89b010e522fd8d683
BLAKE2b-256 7cb47a7a9c3afa33f4513456155d192a0e944c8040b12f65a203d595318f556b

See more details on using hashes here.

Provenance

The following attestation bundles were made for exact_tests-0.5.1-cp312-cp312-macosx_10_13_universal2.whl:

Publisher: release.yaml on chrchang/stats

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file exact_tests-0.5.1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for exact_tests-0.5.1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6e9e32cb076ec7bab878e7b7d7260f88dfa68dba9d11169bb88d43a46f91b331
MD5 01bdbedeca1ba355e9aa9b31a533ec70
BLAKE2b-256 0a2f99e77cdf9fd268b4ad8081c13b6dcf5a202a03222aa7d2daef0766fbb66b

See more details on using hashes here.

Provenance

The following attestation bundles were made for exact_tests-0.5.1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl:

Publisher: release.yaml on chrchang/stats

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file exact_tests-0.5.1-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for exact_tests-0.5.1-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 0fe7abcd6fe0132ce264716b7437d8866b2b1f62de8b04d5874fc68036a0568f
MD5 b56ccb0392511e72a1aa844c661549b0
BLAKE2b-256 bd341e6933e1ca1a164d7441719371f31bdcba4caf7e55d818ca670a7137c67e

See more details on using hashes here.

Provenance

The following attestation bundles were made for exact_tests-0.5.1-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl:

Publisher: release.yaml on chrchang/stats

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file exact_tests-0.5.1-cp311-cp311-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for exact_tests-0.5.1-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 fd6f9c2dd44c237bc7f61b2c2515bbe4d5337b4b1828e08e9a589bd19197ddbf
MD5 e702b0aa95b67dea9d5d99fdc564cb04
BLAKE2b-256 a0bf36632dab2fd874959af7e0e742f110e39e286f9312e8f1d377531105e991

See more details on using hashes here.

Provenance

The following attestation bundles were made for exact_tests-0.5.1-cp311-cp311-macosx_10_9_universal2.whl:

Publisher: release.yaml on chrchang/stats

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file exact_tests-0.5.1-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for exact_tests-0.5.1-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 890797fa0a379588df91e51602b73109fa8c344c800429483cd8fbfa8c6a19fa
MD5 5d60d399ede9aa676cf6efe5266cb3f2
BLAKE2b-256 5fcad31ec5f5772b54bc52e56ac49496cf93751c28c0b8415b92a39cb30294d3

See more details on using hashes here.

Provenance

The following attestation bundles were made for exact_tests-0.5.1-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl:

Publisher: release.yaml on chrchang/stats

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file exact_tests-0.5.1-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for exact_tests-0.5.1-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 90195ed8832b647b6c4203759a8060462b9065339ae94180557d11555389b352
MD5 b8a0adde89c4b9f02f581edddfe7e50a
BLAKE2b-256 225c537c52df2012058efc5a4b0a4c76f18f10eed5075a44a5825bf92ec06913

See more details on using hashes here.

Provenance

The following attestation bundles were made for exact_tests-0.5.1-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl:

Publisher: release.yaml on chrchang/stats

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file exact_tests-0.5.1-cp310-cp310-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for exact_tests-0.5.1-cp310-cp310-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 e9137789bbe8fc15a8a497e905f56f00149414d77e6c41fca0b3b39e12fbec84
MD5 a3f275fec455a54408f05e0c00ce6d51
BLAKE2b-256 41d69f080ab376763dedef372e1109668b9e700f39aa834c8e033c186d85ff2e

See more details on using hashes here.

Provenance

The following attestation bundles were made for exact_tests-0.5.1-cp310-cp310-macosx_10_9_universal2.whl:

Publisher: release.yaml on chrchang/stats

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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