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.0.tar.gz (230.5 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.0-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.0-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.0-cp314-cp314-macosx_10_15_universal2.whl (482.1 kB view details)

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

exact_tests-0.5.0-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.0-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.0-cp313-cp313-macosx_10_13_universal2.whl (478.0 kB view details)

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

exact_tests-0.5.0-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.0-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.0-cp312-cp312-macosx_10_13_universal2.whl (479.6 kB view details)

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

exact_tests-0.5.0-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.0-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.0-cp311-cp311-macosx_10_9_universal2.whl (477.4 kB view details)

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

exact_tests-0.5.0-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.0-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.0-cp310-cp310-macosx_10_9_universal2.whl (477.8 kB view details)

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

File details

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

File metadata

  • Download URL: exact_tests-0.5.0.tar.gz
  • Upload date:
  • Size: 230.5 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.0.tar.gz
Algorithm Hash digest
SHA256 3d03a7af3bf73a941565d64942ae67cc8f73863683128fa56b1f15c9df5c40ba
MD5 ec0c357b19a05316ea74ff80e63a560d
BLAKE2b-256 e6e1c52a312370e276be51d8ab27042b4fd67977e45416620bcd76c7013c36a6

See more details on using hashes here.

Provenance

The following attestation bundles were made for exact_tests-0.5.0.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.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for exact_tests-0.5.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 aaa757a236e2a1ed058983a85c482e15eeb683a73592f2f9caeb3d02d21b3578
MD5 7e55ee56bab883edec67ac122d7cf308
BLAKE2b-256 549793397abc64183e3e70da753ae1a865691314c8294230b346558f727ad451

See more details on using hashes here.

Provenance

The following attestation bundles were made for exact_tests-0.5.0-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.0-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.0-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 a28bda2c1fe9e25af3fcb0e580797afc09dc2cf9bc199598a02a0b888203d7d4
MD5 114ace32962ffcb1afb748ea8743dc97
BLAKE2b-256 28f2101c17f957397d57d93ff55b77721ef0f11810cfa0ef187f29b3886b7599

See more details on using hashes here.

Provenance

The following attestation bundles were made for exact_tests-0.5.0-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.0-cp314-cp314-macosx_10_15_universal2.whl.

File metadata

File hashes

Hashes for exact_tests-0.5.0-cp314-cp314-macosx_10_15_universal2.whl
Algorithm Hash digest
SHA256 4e7a78496b185b37ad4f49625850139eaa514913b776557fae29d5c2638f9d8a
MD5 478036951689872150a6d9f0881d330e
BLAKE2b-256 6c54845417b8aace4e359a7baaabff1f26ea9390f45f8950e016c885ea037035

See more details on using hashes here.

Provenance

The following attestation bundles were made for exact_tests-0.5.0-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.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for exact_tests-0.5.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e1f7a833781247d009dcf3961e3745871be02be44473e3ead12f8e9dbe5a3d76
MD5 4074a0298091d30e2a952c3c5e673a84
BLAKE2b-256 4f1918ecb7cfd08a7bd895f9488e4528d509ea000840090a7872693c81e851af

See more details on using hashes here.

Provenance

The following attestation bundles were made for exact_tests-0.5.0-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.0-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.0-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 31e1f3aabbfd6afdf889d13f1b7acb8a3663a215af31e51fb8a3eda3e8a85b59
MD5 5f223aee9dfe76450a2940d822460e30
BLAKE2b-256 8ecc6bb2f75046d3ed0b19968dd9c2f10cb29fb67e18862d4291ee4fb5709655

See more details on using hashes here.

Provenance

The following attestation bundles were made for exact_tests-0.5.0-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.0-cp313-cp313-macosx_10_13_universal2.whl.

File metadata

File hashes

Hashes for exact_tests-0.5.0-cp313-cp313-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 05cca37ff986945e118eea39867601f0da852484de5611355b4681cf6bf008a5
MD5 01eb8988580764b0c7642a1b38d0775a
BLAKE2b-256 fc535a5593da992642969501dddfbbe2633c78ec02ec9495f99fa62a3dd0f8ae

See more details on using hashes here.

Provenance

The following attestation bundles were made for exact_tests-0.5.0-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.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for exact_tests-0.5.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 f877eb86c25e40a05b1e4d471e4f5a7b82a9a157778a50cc16a554cf07eba5e8
MD5 442c75ea56dca883d0ae070670cf51b9
BLAKE2b-256 11adfb8cfaf6167635e29655d559610e2d90524c6af2d4b335914f0e11287ab1

See more details on using hashes here.

Provenance

The following attestation bundles were made for exact_tests-0.5.0-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.0-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.0-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 f44c52dc89e3b23295fb5fea38934862c912932dba25e2d08881c4701250f921
MD5 d7ee9b682e1c21b50069bcf586cc8864
BLAKE2b-256 9aae5f77a16e8acb510121fe5388719ec2caab778fe7ddbd4f6788b3694c8fbb

See more details on using hashes here.

Provenance

The following attestation bundles were made for exact_tests-0.5.0-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.0-cp312-cp312-macosx_10_13_universal2.whl.

File metadata

File hashes

Hashes for exact_tests-0.5.0-cp312-cp312-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 a483934d88dccd03bff5d67a8a355bc365f228f4525c9bed5c21311067f88bd5
MD5 5ab9c57c335af4d52d164f8e16a852f9
BLAKE2b-256 8149586c3fc5c3255305c5bef22604d1207e929a73ffa10142e0b5dfcf1d06e6

See more details on using hashes here.

Provenance

The following attestation bundles were made for exact_tests-0.5.0-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.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for exact_tests-0.5.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ed648b7d7ecb8baefcb1e39163b0e78288a113e81e3462cfb6bf0897c4c21fe1
MD5 5502a8694937867bf5508e9070ad89b2
BLAKE2b-256 79b97e52709b253abce5785f608b6139a5d0206e117f979eadef8b4ffcf288fc

See more details on using hashes here.

Provenance

The following attestation bundles were made for exact_tests-0.5.0-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.0-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.0-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 147fa5d6b93bccb244c1ae32ef1bd5d27160700a9d086d378443de95d2dc9c66
MD5 15db8258ffd8feb70c0deedb37e79543
BLAKE2b-256 5e6bd24494d0e6090d33822ac632187894972cfc669fbaf695d2d847f66e53c4

See more details on using hashes here.

Provenance

The following attestation bundles were made for exact_tests-0.5.0-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.0-cp311-cp311-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for exact_tests-0.5.0-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 66089da61da1374146116302b820f67b5b3c38dc89cbe8e0bc421662a9bb92e2
MD5 4cde4532c6ead892c76bff29f0276909
BLAKE2b-256 d07ee663737d4d6329888ba22164b1e66b6880d8bfa3ddbdb00e750b230f5719

See more details on using hashes here.

Provenance

The following attestation bundles were made for exact_tests-0.5.0-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.0-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for exact_tests-0.5.0-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 152b1ca52e3fdc8dadaa6bea339a46f3504d8b338130c8bcf6117e675f7c22af
MD5 dc6333a715a998cc9bd956aaad5baef7
BLAKE2b-256 4ab557806a0a697dd2c5610ffa870ed184c80b79d7dff430a7f390d22e0aa158

See more details on using hashes here.

Provenance

The following attestation bundles were made for exact_tests-0.5.0-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.0-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.0-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 726d9cf9914dcc7c50a16b51377fbd60da10f0f5e0959d8e5cf47a657d3affb8
MD5 c6c19a07ae93ec6f7778c06efa80e9fc
BLAKE2b-256 0dac8cf70cf0844a2db515132074c0fbefb0893add161c624f1f55ed12182ca8

See more details on using hashes here.

Provenance

The following attestation bundles were made for exact_tests-0.5.0-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.0-cp310-cp310-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for exact_tests-0.5.0-cp310-cp310-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 7f5fff5a9e45cdc0ca829639fa200710546d57c800b381b0ba51af46f84b29d6
MD5 a00cc42ddd8db3d09f424cbd7eb17168
BLAKE2b-256 000e0709d05c07f8811f250cef7a5075ddc116edec6610f16a40d3a0fea37f1f

See more details on using hashes here.

Provenance

The following attestation bundles were made for exact_tests-0.5.0-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