Skip to main content

barnard-exact

Free core of Barnard: Barnard's and Boschloo's exact tests for 2x2 tables.

The problem You ran a small 2x2 experiment and Fisher's exact test came back just above your threshold. Fisher's test conditions on the total number of successes, which your experiment never fixed in advance, and that conditioning throws away power. scipy does not implement the unconditional alternatives. Search terms: Barnard test Python pip, Boschloo test Python, Barnard exact test 2x2.

What it does barnard_test(table) and boschloo_test(table) compute the exact unconditional two-sided p-values, maximized over the nuisance parameter, with ties classified in exact integer arithmetic. Boschloo's never returns a larger p-value than Fisher's exact test. Both are validated against published reference values. The free version handles total N up to 200.

Limits Free version: total N <= 200. Larger tables are refused outright instead of hanging. No CLI, no plots, no batch mode.

Install

pip install barnard-exact

Needs Python 3.9 or newer, NumPy, and SciPy.

from barnard_exact import barnard_test, boschloo_test
print(barnard_test([[7, 12], [3, 18]]))
print(boschloo_test([[7, 12], [3, 18]]))

This is the free core: Barnard's and Boschloo's exact tests for 2x2 tables, capped at total N <= 200. The full version ($30, one-time) is uncapped: https://groundplane0.gumroad.com/l/conxfk

Metadata

Release files for barnard-exact 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for barnard-exact 0.1.0
File Size Uploaded
barnard_exact-0.1.0.tar.gz 10.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for barnard-exact 0.1.0
File Interpreter ABI Platform
barnard_exact-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 19.4 kB

Release files / barnard_exact-0.1.0.tar.gz

Download URL barnard_exact-0.1.0.tar.gz
Size 10.2 kB
Tags Source
SHA-256 checksum
How to use checksums
5085d452e7830d9283ea039bb90593db2a449551d8fb2de590ca4a4448ba5d49
BLAKE2b-256 checksum
How to use checksums
458a29ee196b11210bcb43317dacc616dcd9538479e05d53ea8afe974226342f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / barnard_exact-0.1.0-py3-none-any.whl

Download URL barnard_exact-0.1.0-py3-none-any.whl
Size 9.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3bcead59a476a2cbd0fac2e07deb50cff9623a85e3f7b1121dbc1b06b695804e
BLAKE2b-256 checksum
How to use checksums
2ff01e05bf9e5c6ae33f95d72652151e477a61df3b44eb828021b910e7eb7c0c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page