# Chi-square test calculator > How well do the counts match what you expected? Goodness-of-fit and independence tests of counts: χ², degrees of freedom, p-value and expected counts, drawn live. Test counts against expected proportions or a contingency table for independence: χ², p-value, expected counts and Cramér's V, with live charts. - Page: https://how.box/chi-square/ - Runs entirely in the browser. - License: HowToolbox's own text and data (titles, explanations, FAQs, tool descriptions and schemas, this file) are CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/); AI training and answers are welcome. Attribute "HowToolbox (how.box)" with a link to the page used. Third-party data keeps its own terms; the name and logo are not licensed. Publisher: HowToolbox, contact@how.box. Terms: https://how.box/about/terms/ ## Inputs Answer link: https://how.box/chi-square/?t={t}&o={o}&e={e}&tab={tab}&a={a} - `t` (fit or independence): fit or independence. Example: `fit`. - `o` (text): Observed counts (fit). Example: `315 108 101 32`. - `e` (text): Expected proportions or counts (fit); empty for equal. Example: `9 3 3 1`. - `tab` (text): The table, one row per line (independence). Example: `10 20 30 40`. - `a` (number 0.1 to 50): Significance level in percent. Example: `5`. Example answer: https://how.box/chi-square/?t=fit&o=315+108+101+32&e=9+3+3+1&tab=10+20%0A30+40&a=5 A complete link carries the primary answer in the page HTML; a missing or invalid value shows the default page. ## Agent tools - `chi_square_calculate`: Pearson's chi-square tests of counts. - MCP, one POST to https://how.box/mcp: `{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"chi_square_calculate","arguments":{"test":"fit","observed":"315 108 101 32","expected":"9 3 3 1","table":"10 20\n30 40","significance":5}}}` - GET: https://how.box/mcp/run/chi_square_calculate?test=fit&observed=315+108+101+32&expected=9+3+3+1&table=10+20%0A30+40&significance=5 ## How it works A chi-square test asks whether counts differ from what a hypothesis predicts by more than chance would explain. It adds up, over every category, the squared difference between the observed count O and the expected count E, divided by E: χ² = Σ (O − E)² ÷ E. The larger χ², the worse the fit; the p-value is the chance of a χ² at least this large if the hypothesis were true. For goodness of fit, the expected counts are the total times each expected proportion, and the degrees of freedom are the number of categories minus one. Mendel's 556 peas, 315, 108, 101 and 32 against a 9 : 3 : 3 : 1 ratio, expect 312.75, 104.25, 104.25 and 34.75, giving χ² ≈ 0.47 with 3 degrees of freedom and p ≈ 0.93: a very good fit. For a table, each cell expects row total × column total ÷ grand total if rows and columns are independent, with (rows − 1)(columns − 1) degrees of freedom. The method follows the NIST/SEMATECH e-Handbook of Statistical Methods. The test needs counts of independent observations, not percentages or measurements. The χ² approximation is doubtful when expected counts are small (a common rule: all at least 5); then merge categories or use an exact test. A significant result says the counts differ, not why. ## FAQ **What is the difference between goodness of fit and independence?** Goodness of fit compares one set of counts with fixed expected proportions, such as a fair die or a genetic ratio. Independence asks whether two classifications of the same subjects, the rows and columns of a table, are related. **Can I enter percentages?** As expected proportions, yes: 25 25 50 works like 1 1 2. The observed values must be counts, because the test depends on how many observations there are. **Does a small p-value mean a strong association?** No. A large sample can make a small association statistically significant. Use Cramér’s V alongside the p-value to judge the strength of an association in a table. **Does a large p-value prove my expected proportions are correct?** No. It means these data do not provide enough evidence against the expected proportions at the chosen significance level. A small sample can miss a real difference. **Can I test repeated measurements from the same people?** Not with this ordinary chi-square test. Its observations must be independent; paired or repeated categorical data need a method designed for that dependence. More: [HowToolbox index](https://how.box/llms.txt) · [Agent Skill](https://how.box/skill.md) · [agent terms](https://how.box/about/agents/)