Statistics

Fisher's Exact Test Calculator for 2 × 2 and Larger (r × c) Tables, with G-Test

When a contingency table has small counts, the chi-square test can be wrong. Paste your table (2 × 2, 3 × 4 or any size) to get Fisher’s exact p-value, computed the same way as R’s fisher.test (the Freeman–Halton extension for tables larger than 2 × 2). You also get the G-test (likelihood-ratio χ²) with Williams’ correction, Pearson’s χ² for comparison, expected counts, standardised residuals and Cramér’s V.

✅ No login needed100% freeRuns in your browserYour data stays on your device
Fisher's Exact Test and G-Test Calculator✅ Free · no login📚 Cite this tool
Your data never leaves your PC. Your data is analysed on your own computer or phone, even when you upload a CSV or Excel file. Nothing is uploaded, stored or seen by Codanics, and no login is needed.
  • PriceFree, no login or sign-up needed
  • Your dataProcessed in your browser, never uploaded
  • Works onPhone, tablet or computer, any modern browser
  • Made byDr. Muhammad Aammar Tufail, Codanics
  • Published17 November 2026
  • Last updated16 November 2026

📚 How to cite this tool

This tool is free. If it helped your thesis, paper, report or assignment, please cite it. It keeps the tools free and helps other students find them.

Citation · APA 7th edition

Tufail, M. A. (2026). Fisher's exact test and G-test calculator [Online tool]. Codanics. Retrieved 16 November 2026, from https://codanics.com/tools/fisher-exact-test-calculator/

In-text citation: (Tufail, 2026) · Narrative: Tufail (2026)

The access date is today’s date, filled in automatically. Author: Muhammad Aammar Tufail. Published 17 November 2026.

🚀 Follow Codanics channel on WhatsApp for more updatesNew free tools, scholarships, PhD positions and research tips, straight to your phone. Free lessons on YouTube too.

How to use the Fisher's Exact Test and G-Test Calculator

  1. Paste your table of counts from Excel (with or without row and column names), or type the numbers with one row per line. You can also upload raw data with two category columns; the tool counts them for you.
  2. For a 2 × 2 table you can choose a one-tailed alternative. For larger tables the test is always two-tailed.
  3. Click Run Fisher’s exact test. Large tables are handled automatically: if exact enumeration would take too long, the p-value is estimated from 100,000 random tables.
  4. Read Fisher’s p-value, check the expected counts and residuals to see which cells drive the association, and copy the APA sentence and summary table.

When to use Fisher’s exact test instead of chi-square

The chi-square test is an approximation that works well when expected counts are large. A common rule (Cochran, 1954) is that no expected count should be below 1 and no more than 20% should be below 5. If your table breaks this rule, which is common with small samples, rare outcomes or many categories, use Fisher’s exact test. It calculates the probability of the observed table, and of every more extreme table with the same row and column totals, exactly.

For tables larger than 2 × 2 the test is often called the Freeman–Halton test. This tool computes it exactly for most tables you will meet in a thesis. Very large tables would take too long to enumerate in a browser, so the tool then uses a Monte Carlo estimate, just like R’s simulate.p.value = TRUE.

The G-test (likelihood-ratio chi-square)

The G-test is an alternative to Pearson’s χ² that is popular in biology and ecology (Sokal and Rohlf). It is based on the log-likelihood ratio and is additive, which makes it convenient for more complex designs. Williams’ correction makes it more accurate for small samples. Like the χ² test, it is an approximation, so Fisher’s exact test remains the better choice for small expected counts.

Formulas

P(table) = (∏ Rᵢ! · ∏ Cⱼ!) / (N! · ∏ nᵢⱼ!) Fisher p = sum of P(table) over all tables with the same margins and P(table) ≤ P(observed) Expected Eᵢⱼ = Rᵢ · Cⱼ / N G = 2 · Σ Oᵢⱼ · ln(Oᵢⱼ / Eᵢⱼ), df = (r − 1)(c − 1) Williams: q = 1 + (N·Σ1/Rᵢ − 1)(N·Σ1/Cⱼ − 1) / (6N(r − 1)(c − 1)), G_adj = G / q Adjusted residual = (O − E) / √(E · (1 − Rᵢ/N) · (1 − Cⱼ/N)) Cramér’s V = √(χ² / (N · (min(r, c) − 1)))

For 2 × 2 tables the odds ratio is the conditional maximum-likelihood estimate with an exact confidence interval, the same values R’s fisher.test reports (they differ slightly from the simple ad/bc odds ratio).

Worked example

Pathogens isolated from roots at three sites: Fusarium (5, 1, 0), Pythium (2, 6, 1) and Rhizoctonia (0, 2, 5). With N = 22, all nine expected counts are below 5, so the chi-square test is not appropriate. Fisher’s exact test gives p = .002: the pathogen community differs between sites. The residuals show Fusarium concentrated at site 1, Pythium at site 2 and Rhizoctonia at site 3.

Fisher’s exact test (Freeman–Halton extension) showed a significant association between the row and column variables, p = .002, Cramér’s V = .63, N = 22.
Learn the statistics behind these numbers. Codanics has free statistics, R and Python lessons on YouTube and full courses for researchers.

Frequently asked questions

Can Fisher's exact test be used for tables larger than 2 × 2?

Yes. The Freeman–Halton extension of Fisher’s test works for any r × c table, and that is what this tool and R’s fisher.test compute. For very large tables the exact calculation becomes slow, so the tool switches to a Monte Carlo estimate based on 100,000 random tables.

When should I use Fisher's exact test instead of the chi-square test?

When more than 20% of the expected counts are below 5, or any expected count is below 1. The tool shows the expected counts and tells you how many are below 5. Many journals also accept Fisher’s test for any 2 × 2 table with a small sample.

Why is the odds ratio different from ad/bc?

For 2 × 2 tables, Fisher’s test reports the conditional maximum-likelihood estimate of the odds ratio, which conditions on the table margins. It is usually close to the sample odds ratio ad/bc but not identical. Its exact confidence interval matches the test, which the simple ad/bc interval does not.

What is the difference between the G-test and the chi-square test?

Both compare observed and expected counts and give similar results with large samples. The G-test uses the log-likelihood ratio; the chi-square test uses squared differences. The G-test is popular in ecology and genetics because G values can be added across independent tests.

Is the Monte Carlo p-value reliable?

Yes. With 100,000 random tables the standard error of the estimated p-value is at most 0.0016, and it is shown in the results. The random seed is fixed, so you get the same answer each time.

Is my data uploaded?

No. Everything runs in your browser.

Do I need to log in or create an account to use the Fisher's Exact Test and G-Test Calculator?

No. There is no login, no sign-up and no email required. Open the page and start using it straight away, for free, on any device.

How do I cite this tool in my thesis or paper?

Use the citation box on this page. In APA 7th edition: Tufail, M. A. (2026). Fisher's exact test and G-test calculator [Online tool]. Codanics. Retrieved [date you used it], from https://codanics.com/tools/fisher-exact-test-calculator/. BibTeX, RIS (EndNote, Mendeley, Zotero), MLA, Harvard, Chicago and Vancouver formats are also available.

Free guides and courses from Codanics

More free tools

See all free Codanics tools → · Codanics on YouTube · WhatsApp channel

Made by Dr. Muhammad Aammar Tufail, Codanics. First published 17 November 2026, last updated 16 November 2026. Found a bug or have an idea for a new tool? Tell us on the WhatsApp channel or in the comments on YouTube. Results are for learning and planning; check important analyses with a statistician or your supervisor.