ForHosting KIT · Math

Fisher's exact test calculator

The 2x2 table 8, 2, 1, 5 gives a two-sided p-value of 5/143, below the usual 0.05 level. Fisher's exact test stays exact with small samples and near-empty cells, where a chi-square test would come with a warning. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
A
8
B
2
C
1
D
5
You get
N
16
Row1 total
10
Row2 total
6
Col1 total
9

Fisher's exact test answers a single, well-posed question: given a 2x2 contingency table of four non-negative integer counts, how surprising is the observed association if the row and column totals were fixed and the table had been drawn from the hypergeometric distribution? Unlike a chi-square test of independence, Fisher's procedure is exact for small samples and sparse cells; it enumerates every table that shares those margins and sums the hypergeometric probabilities of the tables that are at least as extreme as the one you observed. This calculator accepts the four cell counts a, b, c and d, rejects negative or non-integer values instead of silently rounding, and returns the two-sided p-value under the minimum-likelihood definition used by the classical Fisher exact test.

How Fisher's exact test is defined on a 2x2 table

Write the four observed counts in the usual textbook layout: a in the top-left cell, b top-right, c bottom-left and d bottom-right. The row totals are a plus b and c plus d; the column totals are a plus c and b plus d; the grand total is n equals a plus b plus c plus d. Fisher's argument conditions on those four margins.

Under that conditioning the top-left count is a hypergeometric random variable: the probability of any particular admissible value k is the product of the two row-wise binomial coefficients C(a+b, k) and C(c+d, column-one-total minus k), divided by C(n, column-one-total). Equivalently, the probability of a full table is (a+b)! (c+d)! (a+c)!

(b+d)! divided by n! a! b! c! d!. The admissible range for k runs from max(0, row-one plus column-one minus n) to min(row-one, column-one).

The two-sided p-value reported here is the minimum-likelihood sum used by the classical Fisher exact test and by the default two-sided option in standard statistical libraries: add the hypergeometric probability of every table whose probability is less than or equal to the probability of the table you observed. That is not the same as doubling a one-sided tail, and it is the quantity people mean when they search for a Fisher's exact test calculator.

The engine computes the unnormalized binomial weights with exact BigInt arithmetic and only converts the final ratio to a floating p-value, so small classroom tables such as eight, two, one, five reproduce the textbook fraction rather than a chi-square approximation.

What you send and what you get back

Send four required non-negative integer cell counts named a, b, c and d. A negative count is rejected because a contingency table cannot hold a negative frequency. A non-integer count is rejected because Fisher's exact test is defined on discrete tables, not on silently rounded measurements.

The grand total n is capped so the hypergeometric enumeration stays bounded in the worker. When b and c are both positive the sample odds ratio a times d over b times c is included; when either b or c is zero the odds ratio is undefined and that key is omitted rather than faked as null. Classic checks include the sparse table eight, two, one, five, whose two-sided p-value is five over one hundred forty-three, and a deliberate negative cell that must fail.

Where a 2x2 Fisher exact p-value shows up in real work

Introductory biostatistics and AP-statistics courses constantly assign 2x2 independence drills on small counts—treatment versus control, exposed versus unexposed, recovered versus died—where expected cell frequencies fall below five and a chi-square warning appears in every textbook. Quality and reliability engineers compare pass/fail counts before and after a process change on the same two-by-two layout and need an exact p-value rather than an asymptotic approximation that overstates evidence.

A/B analysts and product researchers sometimes have tiny conversion tables in a holdout slice and want the same two-sided Fisher number that a statistician would quote in a methods appendix. If you later need a chi-square test of independence, a Matthews correlation on the same four cells, Cohen's h for two proportions, or a paired t-test on before-and-after measurements, treat those as separate search intents and landings rather than overloading this Fisher's exact test calculator page.

Small-sample 2x2 homework checks

Students and graders verify the two-sided Fisher p-value from four integer cells without scanning hypergeometric tables or rounding counts by hand.

Sparse clinical and epidemiology tables

Analysts test association in treatment-by-outcome 2x2s when expected counts are small and a chi-square approximation would be misleading.

Process pass/fail before and after a change

Engineers compare two binary classifications on a 2x2 layout and publish the exact two-sided p-value for the observed odds ratio.

How are the four cells a, b, c and d arranged?

They form a 2x2 table: a is row 1 column 1, b is row 1 column 2, c is row 2 column 1, and d is row 2 column 2. Row and column totals are computed from those four counts.

Is the p-value one-sided or two-sided?

Two-sided, using the minimum-likelihood method: the engine sums the hypergeometric probability of every table with the same margins whose probability is at most that of the observed table.

What happens if a cell is negative or not an integer?

Fisher's exact test is defined on non-negative integer counts; fractions and negative frequencies are rejected instead of being rounded.

How is this different from a chi-square test of independence?

Chi-square is an asymptotic approximation that needs large expected counts. Fisher's exact test conditions on the margins and is exact for small and sparse 2x2 tables.

What does it cost?

The browser tool is free and runs locally.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/stat/fishers-exact-test

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/stat/fishers-exact-test \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"a":8,"b":2,"c":1,"d":5}'
{
  "a": 8,
  "b": 2,
  "c": 1,
  "d": 5
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "stat.fishers_exact_test",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

max_n2000
max_cell2000
HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Successful API calls are billed at the published base of $0.002 per item; invalid input is not charged.

What you send and what you get back

The engine also accepts the matrix aliases n11, n12, n21, n22 and a11, a12, a21, a22 so a script that already stores a numeric matrix does not have to rename fields. Each count may arrive as a JSON integer or as a digit string; fractions, booleans, NaN, Infinity, empty strings and missing fields fail with invalid_input that names the offending cell. On success the response echoes the four cells and n, reports the two row totals and two column totals, returns the two-sided p_value rounded to twelve decimal places, flags significant_at_05 at the conventional alpha of 0.05, names the method as two-sided minimum likelihood, and restates the formula. Wire the free browser form for homework and demos, then call the identical contract from scripts when you need many 2x2 tests under one JSON shape. API pricing for successful calls is the published base of $0.002 per item; validation failures do not consume balance and never invent a chi-square stand-in to force a number.

Where a 2x2 Fisher exact p-value shows up in real work

A single trusted oracle that returns cleaned JSON speeds grading without looking up hypergeometric tails by hand. Clinical and epidemiology teams still report Fisher's exact p-value for sparse adverse-event tables, case-control 2x2s, and early-phase binary endpoints when the sample is too small for a chi-square or z-test of proportions to be honest. Because this capability is a pure parse engine, API pricing is the published base of $0.002 per successful item and failed validation does not consume balance.

Read the full KIT documentation →