{
    "name": "Chi-Square Goodness of Fit Calculator",
    "url": "https://calculators.geekmidst.com/calculators/chi-square-goodness-of-fit-calculator",
    "markdown": "https://calculators.geekmidst.com/calculators/chi-square-goodness-of-fit-calculator.md",
    "category": "Statistics & probability",
    "description": "Test whether observed counts match expected proportions: Pearson’s χ² statistic, degrees of freedom, right-tailed p-value, critical value and each category’s share.",
    "summary": "The chi-square goodness-of-fit test asks whether counts in categories are consistent with a set of expected proportions, such as a fair die, a genetic ratio or a planned market share.",
    "also_called": [
        "Chi-square test for given proportions",
        "Pearson chi-square test"
    ],
    "applies_to": "Worldwide",
    "last_updated": "2026-10-29",
    "computation": "Results are computed in the visitor’s browser on the HTML page. This API describes the calculator; it does not compute results.",
    "inputs": [
        {
            "name": "observed",
            "label": "Observed counts",
            "type": "textarea",
            "default": "315, 108, 101, 32"
        },
        {
            "name": "expected",
            "label": "Expected counts or ratios (optional)",
            "type": "textarea",
            "default": "9, 3, 3, 1",
            "optional": true
        },
        {
            "name": "estimated",
            "label": "Parameters estimated from the data",
            "type": "number",
            "default": "0",
            "optional": true
        },
        {
            "name": "alpha",
            "label": "Significance level (α)",
            "type": "number",
            "default": "5",
            "unit": "%"
        }
    ],
    "outputs": [
        {
            "key": "chi2",
            "label": "χ² statistic",
            "format": "number"
        },
        {
            "key": "df",
            "label": "Degrees of freedom",
            "format": "integer"
        },
        {
            "key": "p_value",
            "label": "p-value (right-tailed)",
            "format": "number"
        },
        {
            "key": "p_text",
            "label": "p-value, full precision",
            "format": "text"
        },
        {
            "key": "critical",
            "label": "Critical value at α",
            "format": "number"
        },
        {
            "key": "decision",
            "label": "Decision",
            "format": "text"
        },
        {
            "key": "min_expected",
            "label": "Smallest expected count",
            "format": "number"
        }
    ],
    "formula": {
        "text": "χ² = Σ (O − E)² ÷ E;  df = categories − 1 − estimated parameters;  p = P(χ²_df ≥ observed χ²)",
        "variables": {
            "O": "observed count in a category",
            "E": "expected count = total × expected proportion",
            "df": "degrees of freedom"
        }
    },
    "worked_example": {
        "inputs": {
            "observed": "315, 108, 101, 32",
            "expected": "9, 3, 3, 1",
            "estimated": "0",
            "alpha": "5"
        },
        "steps": [
            "Total = 556. Expected for 9:3:3:1 = 312.75, 104.25, 104.25, 34.75.",
            "χ² = 2.25²/312.75 + 3.75²/104.25 + 3.25²/104.25 + 2.75²/34.75 = 0.016 + 0.135 + 0.101 + 0.218 = 0.470.",
            "With 3 degrees of freedom, P(χ² ≥ 0.470) = 0.925, far above 0.05; the 5% critical value is 7.815."
        ],
        "result": "Mendel’s pea counts fit the 9:3:3:1 ratio very well: χ² = 0.47 with 3 df, p = 0.93."
    },
    "interpretation": "A small p-value means the counts are unlikely under the expected proportions. A large p-value does not prove the proportions are right, only that the data cannot rule them out. The table shows which categories contribute most to the statistic.",
    "assumptions": [
        "Observations are independent and each falls into exactly one category.",
        "Expected counts are at least 5 in every category (a common rule for the chi-square approximation).",
        "The test is right-tailed: only large χ² values count against the null hypothesis."
    ],
    "limitations": [
        "Enter raw counts, not percentages or averages; the statistic depends on the actual sample size.",
        "For small expected counts use an exact multinomial test or merge categories."
    ],
    "rules": null,
    "faqs": [
        {
            "question": "How many degrees of freedom?",
            "answer": "Categories minus one, minus one more for each parameter you estimated from the same data to build the expected counts."
        },
        {
            "question": "Is this the same as the chi-square test of independence?",
            "answer": "No. Independence uses a two-way table and df = (rows − 1)(columns − 1). This test compares one set of counts with fixed proportions."
        }
    ],
    "sources": [],
    "related": [
        {
            "name": "P-value Calculator",
            "url": "https://calculators.geekmidst.com/calculators/p-value-calculator"
        },
        {
            "name": "Binomial Probability Calculator",
            "url": "https://calculators.geekmidst.com/calculators/binomial-probability-calculator"
        },
        {
            "name": "Statistics Calculator",
            "url": "https://calculators.geekmidst.com/calculators/statistics-calculator"
        }
    ],
    "disclaimer": null,
    "publisher": "GM¹X CalcVerse"
}