Home
📊 Goodness of Fit
📋 Test of Independence
0 categories
Category Observed (O) Expected (E)

What Is a Chi-Square Test?

The chi-square (χ²) test is a statistical test used to determine if there is a significant difference between expected and observed frequencies in one or more categories. It is one of the most widely used non-parametric tests for categorical data.

There are two main types of chi-square tests:

  • Goodness of Fit: Tests whether a sample matches a hypothesized distribution (e.g., is a die fair?).
  • Test of Independence: Tests whether two categorical variables are independent of each other (e.g., is gender related to voting preference?).

Chi-Square Formula

χ² = Σ (O − E)² / E

Where O = observed frequency, E = expected frequency

The test compares what you observed in your data against what you would expect if the null hypothesis were true. The larger the chi-square statistic, the more your data deviates from the null expectation.

Degrees of Freedom

  • Goodness of Fit: df = k − 1 (where k = number of categories)
  • Test of Independence: df = (r − 1) × (c − 1) (where r = rows, c = columns)

Expected Frequencies

  • Goodness of Fit: Expected = total observations × hypothesized proportion for each category
  • Test of Independence: E = (row total × column total) / grand total

How to Interpret the Results

  • P-value: The probability of obtaining a chi-square statistic as extreme as the observed one, assuming the null hypothesis is true.
  • If p ≤ α: Reject the null hypothesis , there is a significant difference (or association).
  • If p > α: Fail to reject the null hypothesis , no significant difference (or association).

Why Use This Chi-Square Calculator?

  • Two Test Types: Supports both goodness-of-fit and independence tests.
  • Step-by-Step: See the complete calculation process for every cell.
  • Expected Values: Automatically computes expected frequencies for independence tests.
  • Visual Distribution: See the chi-square distribution with your statistic highlighted.
  • Free & Private: No registration, no data storage.

❓ Chi-Square Calculator FAQ

What is a chi-square test?

A chi-square test is a statistical test used to determine if there is a significant difference between expected and observed frequencies in categorical data. It has two main types: goodness of fit and test of independence.

What is the difference between goodness of fit and independence?

Goodness of fit tests whether a single categorical variable matches a hypothesized distribution. Test of independence tests whether two categorical variables are independent of each other using a contingency table.

What is the chi-square formula?

The chi-square statistic is calculated as: χ² = Σ (O − E)² / E, where O is the observed frequency and E is the expected frequency for each category or cell.

How are expected frequencies calculated?

For goodness of fit, expected frequencies are based on the hypothesized proportions. For independence tests, expected frequencies are calculated as: E = (row total × column total) / grand total.

What is the assumption about expected frequencies?

The chi-square test assumes that expected frequencies are at least 5 in each cell. If any expected value is below 5, the test results may be unreliable and Fisher's exact test may be more appropriate.

What is the p-value in a chi-square test?

The p-value is the probability of obtaining a chi-square statistic as extreme as the observed one, assuming the null hypothesis is true. If p ≤ α, we reject the null hypothesis.

What degrees of freedom should I use?

For goodness of fit: df = k − 1 (categories − 1). For independence: df = (r − 1) × (c − 1) (rows − 1 times columns − 1).

When should I use a chi-square test?

Use a chi-square test when you have categorical (count) data and want to compare observed frequencies to expected frequencies, or test the association between two categorical variables.

Is this calculator free?

Yes, this calculator is completely free to use. No registration or personal data storage is required. All calculations are performed in your browser.