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.2.tar.gz (233.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.2-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.2-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.2-cp314-cp314-macosx_10_15_universal2.whl (487.8 kB view details)

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

exact_tests-0.5.2-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.2-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.2-cp313-cp313-macosx_10_13_universal2.whl (483.7 kB view details)

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

exact_tests-0.5.2-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.2-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.2-cp312-cp312-macosx_10_13_universal2.whl (485.2 kB view details)

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

exact_tests-0.5.2-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.2-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.2-cp311-cp311-macosx_10_9_universal2.whl (483.0 kB view details)

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

exact_tests-0.5.2-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.2-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (1.5 MB view details)

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

exact_tests-0.5.2-cp310-cp310-macosx_10_9_universal2.whl (483.3 kB view details)

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

File details

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

File metadata

  • Download URL: exact_tests-0.5.2.tar.gz
  • Upload date:
  • Size: 233.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.2.tar.gz
Algorithm Hash digest
SHA256 b7533af7a508b1528e9b39f13f9f0a0da9dffa17af5abcf2d0e005429f68aacc
MD5 99c410c0f063e25b11346ba686983da6
BLAKE2b-256 89cbeb2c60bf03c0c808ddb7cc761a08b3d371d9478ee5a7d82b4fbf26f248a6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for exact_tests-0.5.2-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 138ee17ead476022fcdd4f88e9f95c21689b35a8fa6bdf6b80cfce56e7e757a4
MD5 d98427e7ebabac4a47e22a1e858bdfc4
BLAKE2b-256 800cc8e02dfdacb5ba085b9a769768326397516662fb03d1fef1add5c8fdef7b

See more details on using hashes here.

Provenance

The following attestation bundles were made for exact_tests-0.5.2-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.2-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.2-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 efe25683ad83c24aadb4ed154ce2751c0560cab5cb99d6ecbef816128abd1d56
MD5 21e872ac9db6b7ee0a6772cde489662a
BLAKE2b-256 a1deb6086c3e601a9dfc1c45332deb2c6bdf7c13386dffd2f3eb6c602186e2ec

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for exact_tests-0.5.2-cp314-cp314-macosx_10_15_universal2.whl
Algorithm Hash digest
SHA256 a0fc62fb23a2cf7ec2c667fe423a128ee980f7de3643b6a5087b26405244cfd8
MD5 1943b56a087317534661144e5996c79b
BLAKE2b-256 ce0d7a1dbdd57e5913cdbf0721e34bb3056e5360780bb9853dbdbdcd82a8bfd0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for exact_tests-0.5.2-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 aa6eebba283a1935a2750a4a7dc9b386b7be7e633f7a8dfffabda8c448b670d4
MD5 14404568e050131a7ddf8e5cbab06937
BLAKE2b-256 ccb36ae8629cdfb355d417887ead61ca45c6837333fb6c0def3fa43bad762336

See more details on using hashes here.

Provenance

The following attestation bundles were made for exact_tests-0.5.2-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.2-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.2-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 16d09f2f108c562e99809028adec84556da18d9a2a353d1e60ae3bb59ad82661
MD5 7eea13fc087e325ed6f31a6a1d370183
BLAKE2b-256 be9dddee8bac90c96a6ee1c06db8c517a98a6a6fcc89afff775b15242b406373

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for exact_tests-0.5.2-cp313-cp313-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 593cd90a524d08c8029afc45ea57b528712e78ba6b03bf30de8ab6ec7b0ac1e3
MD5 2aa826384dd610ca90da7182aba6da4d
BLAKE2b-256 0be14baf2f1a0f3f1725793179db36a394b3acd94f174374b394f7fdd1df96f5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for exact_tests-0.5.2-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 08be93d9166e29a95b0d6dc4f218da46ecc2e367ece4b1fae55b9402a4b34fda
MD5 0bd6484be64eafb47f1379cdd3e5fb05
BLAKE2b-256 dfa717ded49861710cdb67b41af1cab115f7132bfb74de3a854fb4bb4a7faa63

See more details on using hashes here.

Provenance

The following attestation bundles were made for exact_tests-0.5.2-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.2-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.2-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 ca5bd7616fa9a9cb05e75fe804bb6ab20320861b9db495b5fde3c263c0e5ad0d
MD5 cba1a521cb146e102a0dddab2411089b
BLAKE2b-256 270cb4cce45c3a90dcd35164b13cdf90f38af290398645eb8cc6b42601555c22

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for exact_tests-0.5.2-cp312-cp312-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 4a542d804ea30c27da7bc2f2c44983298fd6e674c6c54fe99ff5c8f2fca2cec9
MD5 8ea548b764fa2e85ebaf59d8dc065246
BLAKE2b-256 7955cb77df7ab83f7ac53ba07f5d92f8d76d102bbcd98e09f9be04e2c6519158

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for exact_tests-0.5.2-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6056861e977b08816ad418194d1247c94c1304e158558058093f71d895b54182
MD5 9e994b649adef9e7d1152668a2a36286
BLAKE2b-256 0e961e62e86955a1b4326d56d4d8317f19649f8d7b86b920d939a715424132c3

See more details on using hashes here.

Provenance

The following attestation bundles were made for exact_tests-0.5.2-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.2-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.2-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 f91ca14cf3f7bf1c0dd533934fe613eefa4e33d76c6ae8607d93b54bfebe12d3
MD5 efc3295369711bd91b81330fed565ba5
BLAKE2b-256 2020cee191509eb490d588db129fa8606c83bdc5db1ca5cf7a0e8b669043b5fb

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for exact_tests-0.5.2-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 63ae7a5452956053e1190173a378da7dec0e70af3133041421dd00ee16b14006
MD5 e709a24c07e8db27b2b9aae3293971d4
BLAKE2b-256 fab7c0c6993aae42f463000a251625a000095a87f6bc3ec0de8bcbe14f95acc6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for exact_tests-0.5.2-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ce309d9feac862ef59b0f5e8f80ba10e0cb52274d8c61892d8df6c2af4b29fbe
MD5 5f76346c0fd93af2184a83ca79157668
BLAKE2b-256 2e8cd6fa773dc58924d28d0737e7a91a292c42eb13883e438f84bc1ab0ef8fc9

See more details on using hashes here.

Provenance

The following attestation bundles were made for exact_tests-0.5.2-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.2-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.2-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 8dbb983efea3b1857fe999b367bbc2770741e7bea43e4f508f7f08b6eacdc233
MD5 0b0991a89c2de1c62da4ac1c0459fe4e
BLAKE2b-256 a617f71503534411dc22af8ee5561419010b78a1b15ffae8de6976dda40033dc

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for exact_tests-0.5.2-cp310-cp310-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 a48865f72257547e3a6ab840ec62fb7eecbb0433c442b9fde1c789e21e2837d2
MD5 e4212e0bd7560937b928045e7080b099
BLAKE2b-256 0f178359fcfc2e761d3d15abc4bfd162a3d3ddeb5a290cd357b344a01776df46

See more details on using hashes here.

Provenance

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