Chi-Square Goodness of Fit Calculator

This calculator computes the chi-square goodness-of-fit test statistic, which measures how well a set of observed frequencies matches what you expected. The goodness-of-fit test answers a common statistical question: do my observed counts differ from a theoretical or expected distribution by more than chance would explain? You might test whether a die is fair by comparing the counts of each face against an even spread, whether customers are evenly distributed across days, or whether observed outcomes fit a hypothesised proportion. The chi-square statistic captures the total discrepancy by summing, for each category, the squared difference between observed and expected, divided by the expected. A small statistic means the observed data fits the expected distribution well; a large one suggests a real difference. This tool calculates it. You enter your observed frequencies in one box and the expected frequencies in another, in the same order, and the calculator returns the chi-square statistic, the degrees of freedom (the number of categories minus one), the number of categories, and the total observed count. The results update as you type. Use it for statistics homework, for testing whether data fits a distribution, or as the first step of a goodness-of-fit test. To complete the test, you compare the statistic against a critical value from the chi-square distribution at your chosen significance level and the calculated degrees of freedom, or find the p-value; if the statistic exceeds the critical value, the difference is significant. This calculator gives the statistic and degrees of freedom, the parts that depend on your data, leaving the comparison against a chi-square table to you. Each expected frequency should be reasonably large, commonly at least five, for the test to be reliable.

0.8
chi-square statistic
Degrees of freedom4
Categories5
Observed total100

Chi-square = sum of (observed - expected)² / expected. Degrees of freedom = categories - 1. Compare against a chi-square table to judge significance. Expected counts should be ~5 or more.

How it works

For each category, the calculator finds the difference between the observed and expected frequency, squares it, and divides by the expected frequency. Summing these across all categories gives the chi-square statistic. The degrees of freedom equal the number of categories minus one. A larger statistic indicates a greater discrepancy from the expected distribution.

Worked example

For observed counts 18, 22, 20, 18, 22 against an expected 20 in each of five categories, the squared differences are 4, 4, 0, 4 and 4, each divided by 20 giving 0.2, 0.2, 0, 0.2 and 0.2. The chi-square statistic is their sum, 0.8, with 4 degrees of freedom, a small value suggesting the data fits the expected distribution well.

Related calculators

If you've found a bug, or would like to contact us, or learn more about James Graham and Calculate.co.nz.

Calculate.co.nz is partnered with Interest.co.nz for New Zealand's highest quality calculators and financial analysis.

All calculators and tools are provided for educational and indicative purposes only and do not constitute financial advice.

Calculate.co.nz is proudly part of the Realtor.co.nz group, New Zealand's leading property transaction literacy platform, helping Kiwis understand the home buying and selling process from start to finish. Whether you're a first home buyer navigating your first property purchase, an investor evaluating your next acquisition, or a homeowner planning to sell, Realtor.co.nz provides clear, independent, and trustworthy guidance on every step of the New Zealand property transaction journey.

Calculate.co.nz is also partnered with Health Based Building and Premium Homes to promote informed choices that lead to better long-term outcomes for Kiwi households.

Calculate.co.nz is hosted in Auckland via SiteHost new Zealand.

All content on this website, including calculators, tools, source code, and design, is protected under the Copyright Act 1994 (New Zealand). No part of this site may be reproduced, copied, distributed, stored, or used in any form without prior written permission from the owner.

© 2019 to 2026 Calculate.co.nz. All rights reserved.