BY: Statistics Fundamentals Team
Reviewed By: Minsa A (Senior Statistics Editor)

Chi-Square Distribution Visualizer & p-Value Calculator

The chi-square distribution is a continuous, non-negative probability distribution determined entirely by its degrees of freedom. It is defined as the sum of squared independent standard normal variables: χ²ₖ = Z₁² + Z₂² + ... + Zₖ², where each Zᵢ ~ N(0,1). Adjust the degrees of freedom below and watch the curve change in real time.

Chi-Square Distribution Visualizer

Distribution χ²(k) = sum of k squared standard normals Support x ≥ 0

Chi-square PDF with df=5

p-value
Critical value
Mean
Variance

Probability Results

p-value (upper tail)
Lower tail P(X ≤ χ²)
PDF at χ² (f(x))
Critical value (α)
Decision (upper-tail)

Distribution Properties

Mean E(X)
Variance Var(X)
Std deviation SD(X)
Mode max(k−2, 0)
Skewness √(8/k)
Formula p = P(X ≥ χ²) = 1 − Γ(k/2, χ²/2) / Γ(k/2)

Must be ≥ 0

Positive integer (or real > 0)

Goal Find χ²_crit such that P(X ≥ χ²_crit) = α
Purpose Compare how df changes the chi-square PDF shape

How Degrees of Freedom Change the Chi-Square Distribution

Every property of the chi-square distribution is a direct function of k, the degrees of freedom. Drag the slider above and you will see this directly: as k grows, the curve shifts right, the peak moves away from zero, and the heavy right skew gradually flattens.

df (k) Mean Variance Mode Skewness General shape
11202.828Extremely right-skewed; pole at zero
22402.000Exponential-shaped decay from zero
33611.633Right-skewed; peak above zero
551031.265Moderately right-skewed
10102080.894Less skewed; clear unimodal peak
202040180.632Noticeably more symmetric
303060280.516Approximately bell-shaped
5050100480.400Nearly symmetric; still bounded at 0

For large k, the chi-square distribution can be approximated by a normal distribution with mean k and variance 2k: X ≈ N(k, 2k). The standardized form Z ≈ (X − k) / √(2k) approaches the standard normal. This approximation is useful in practice but the chi-square distribution remains bounded below by zero — unlike the normal, which extends across the entire real line.

The Mathematics Behind the Chi-Square Distribution

The chi-square distribution with k degrees of freedom has the following probability density function, defined for x ≥ 0:

Chi-square PDF — f(x; k) f(x; k) = x^(k/2 − 1) · e^(−x/2) / [ 2^(k/2) · Γ(k/2) ]
Chi-square CDF — F(x; k) F(x; k) = γ(k/2, x/2) / Γ(k/2) — regularized incomplete gamma function
Upper-tail probability (p-value for most chi-square tests) P(X ≥ x) = 1 − F(x; k) = Γ(k/2, x/2) / Γ(k/2)

The Gamma function Γ(k/2) appears here as the normalizing constant. For positive integer k, when k is even, Γ(k/2) = (k/2 − 1)!. When k is odd, the gamma function takes non-integer values. The calculator above computes all results using a numerically stable series expansion of the regularized incomplete gamma function, so tail probabilities remain accurate even at extreme values.

Why Chi-Square Values Cannot Be Negative

The chi-square variable is constructed by summing squared quantities: χ²ₖ = Z₁² + Z₂² + ... + Zₖ². Squaring any real number produces a non-negative result. The sum of non-negative values is also non-negative. This is why the left boundary of every chi-square distribution is exactly zero — and why the x-axis in the visualizer above never shows values below zero.

This also explains the right skew. At low degrees of freedom, most of the probability mass sits near zero, with a long tail extending right. As you add more squared normal components, the distribution spreads out, its peak moves right, and the heavy tail becomes proportionally smaller.

Connection to the Gamma Distribution

The chi-square distribution with k degrees of freedom is a special case of the Gamma distribution: χ²ₖ ~ Gamma(shape = k/2, scale = 2). This relationship is useful in mathematical statistics and provides a general framework for the chi-square's properties. For most applied work involving p-values and critical values, the chi-square form is the one you will encounter directly.

Where the Chi-Square Distribution Is Used

Several distinct statistical tests produce a chi-square statistic and use this distribution to find p-values. Each test has its own degrees-of-freedom formula and slightly different assumptions.

Goodness-of-Fit Test — Tests whether observed category counts match a specified distribution.
Test statistic χ² = Σ (Oᵢ − Eᵢ)² / Eᵢ
Degrees of freedom (C categories, no estimated parameters) df = C − 1

Each estimated parameter reduces df by one additional degree. Oᵢ = observed count in category i; Eᵢ = expected count under the null model. A large χ² statistic indicates that observed counts differ substantially from expected counts.

Test of Independence — Tests whether two categorical variables in a contingency table are independent.
Degrees of freedom (R rows, C columns) df = (R − 1)(C − 1)
Expected cell count Eᵢⱼ = (row total × column total) / grand total

Observed cell counts are compared to expected counts under the assumption of independence. A large χ² statistic suggests the two variables are not independent in the population.

Test of Homogeneity — Tests whether the distribution of a categorical variable is the same across different populations or groups.
Degrees of freedom df = (R − 1)(C − 1) — same formula as independence

The computation proceeds the same way as an independence test, but the research question is different: you are asking whether categorical proportions are homogeneous across groups, rather than whether two variables within one population are associated.

Chi-Square Test for a Single Variance — Tests whether a population variance equals a specific hypothesized value σ₀².
Test statistic (requires normality of the underlying data) χ² = (n − 1) · s² / σ₀²
Degrees of freedom df = n − 1

This application carries a stronger distributional assumption than categorical chi-square tests: the individual data values must be approximately normally distributed. Here s² is the sample variance and n is the sample size.

p-Value vs Critical Value Approach

Both methods answer the same question — reject H₀ or not — and produce identical conclusions when applied correctly.

MethodDecision ruleWhat you need
p-value approachReject H₀ if p ≤ αχ² statistic, df, chosen α
Critical value approachReject H₀ if χ²_obs > χ²_critical (upper tail)df, chosen α — look up table or calculate

Chi-Square Critical Value Table

The values below are upper-tail critical values: P(X ≥ χ²_critical) = α. Use the interactive visualizer above for df values beyond 30 or for significance levels not listed here. See the full chi-square critical value table for an extended reference.

df α = 0.10 α = 0.05 α = 0.01 α = 0.001
12.7063.8416.63510.828
24.6055.9919.21013.816
36.2517.81511.34516.266
47.7799.48813.27718.467
59.23611.07015.08620.515
610.64512.59216.81222.458
712.01714.06718.47524.322
813.36215.50720.09026.124
914.68416.91921.66627.877
1015.98718.30723.20929.588
1218.54921.02626.21732.909
1522.30724.99630.57837.697
2028.41231.41037.56645.315
2534.38237.65244.31452.620
3040.25643.77350.89259.703

All values are upper-tail critical values verified against the regularized incomplete gamma function. For additional df and α values, use the visualizer's Critical Value tab above or visit the chi-square table.

Worked Examples

Example 1: Goodness-of-Fit Test

A researcher expects four product categories to attract equal customer interest. Observed counts from a survey of 200 customers: Category A = 60, B = 45, C = 55, D = 40.

Step 1 — Expected counts: Under equal proportions, Eᵢ = 200/4 = 50 for each category.
Step 2 — Chi-square statistic: χ² = (60−50)²/50 + (45−50)²/50 + (55−50)²/50 + (40−50)²/50 = 100/50 + 25/50 + 25/50 + 100/50 = 2.0 + 0.5 + 0.5 + 2.0 = 5.0
Step 3 — Degrees of freedom: df = C − 1 = 4 − 1 = 3
Step 4 — p-value: P(X ≥ 5.0 | df=3) ≈ 0.172. The critical value at α=0.05 is 7.815.
Conclusion: p = 0.172 > 0.05, so we fail to reject H₀. The data are consistent with equal category proportions.

Example 2: Test of Independence (2 × 3 Table)

A researcher tests whether preference (Low, Medium, High) is independent of customer type (Existing, New). Observed counts: Existing: 30, 50, 20; New: 20, 40, 40.

Degrees of freedom: df = (R−1)(C−1) = (2−1)(3−1) = 2
Grand total: N = 200. Row totals: Existing = 100, New = 100. Column totals: Low = 50, Medium = 90, High = 60.
Expected counts (E = row × col / N): E(Existing, Low) = 100×50/200 = 25; E(Existing, Med) = 45; E(Existing, High) = 30; E(New, Low) = 25; E(New, Med) = 45; E(New, High) = 30.
Chi-square statistic: χ² = (30−25)²/25 + (50−45)²/45 + (20−30)²/30 + (20−25)²/25 + (40−45)²/45 + (40−30)²/30 ≈ 1.0 + 0.556 + 3.333 + 1.0 + 0.556 + 3.333 ≈ 9.778
Critical value (df=2, α=0.05): 5.991. Since 9.778 > 5.991, reject H₀. p ≈ 0.0075. There is significant evidence that preference is not independent of customer type.

Example 3: Critical Value at df=5, α=0.05

Critical value: χ²_critical ≈ 11.070. Suppose an observed statistic is χ² = 14.0.
p-value approach: P(X ≥ 14.0 | df=5) ≈ 0.015. Since 0.015 < 0.05, reject H₀.
Critical value approach: 14.0 > 11.070, which places the statistic in the rejection region. Reject H₀. Both methods agree.

Chi-Square vs Other Distributions

PropertyChi-square (χ²)t-distributionF-distribution
Supportx ≥ 0All real numbersx ≥ 0
Parametersdf = kdf = νdf₁, df₂
Shape at low dfRight-skewedSymmetric, heavy tailsRight-skewed
Bounded below?Yes — at zeroNoYes — at zero
Can take negative values?NoYesNo
Meank0 (ν > 1)df₂/(df₂−2) (df₂ > 2)
Common usesCategorical tests, varianceMean comparisonsVariance ratios, ANOVA
Relationshipχ²(k) = sum of k squared normalsNormal / √(χ²/k)χ²(d₁)/d₁ ÷ χ²(d₂)/d₂

When Is a Chi-Square Test Appropriate?

The chi-square approximation works best when expected cell counts are reasonably large. Many textbooks use a rule of thumb that expected counts should be at least 5 in each cell, though this is a practical guideline rather than an absolute requirement. The appropriateness of the approximation depends on the table structure, the overall sample size, and the specific test.

When expected counts are very small — particularly in sparse contingency tables — Fisher's exact test is often more appropriate. Fisher's exact test does not rely on a large-sample approximation and is exact for 2×2 tables regardless of cell counts.

Common Chi-Square Distribution Mistakes

  • Assuming chi-square values can be negative. They cannot. The distribution is bounded below by zero.
  • Confusing df with sample size. Degrees of freedom depend on the test structure, not directly on n.
  • Using the wrong tail. Most chi-square tests use the upper tail (larger statistics → more evidence against H₀).
  • Confusing p-value with α. The p-value is calculated from your data; α is a threshold set before seeing the data.
  • Assuming df = number of categories. For goodness of fit it is C−1, not C.
  • Forgetting estimated parameters reduce df. Each parameter estimated from the data removes one degree of freedom.
  • Claiming large df makes the distribution exactly normal. It becomes approximately normal in shape, but it remains bounded at zero.
  • Ignoring expected count assumptions. Very small expected counts can make the chi-square approximation unreliable.

Frequently Asked Questions

A chi-square distribution is a continuous probability distribution that takes only non-negative values. It is parameterized entirely by its degrees of freedom k. Mathematically, a chi-square variable with k degrees of freedom equals the sum of k squared independent standard normal variables: χ²ₖ = Z₁² + Z₂² + ... + Zₖ². It is commonly used in hypothesis tests involving categorical data, variances, and goodness-of-fit assessments.

Squaring standard normal variables produces values that cluster near zero (because small values are common in a standard normal) while allowing occasional large values when the normals take large positive or negative values. The sum of a few squared normals still produces a distribution with more probability near zero than far from it, creating a right skew. As more squared normals are added (higher df), the skew decreases because the central limit effect begins to apply to the sum.

No. Chi-square values are always zero or positive. The distribution is the sum of squared quantities, and squaring any real number — positive, negative, or zero — produces a non-negative result. The left boundary of the chi-square distribution is exactly zero. A chi-square statistic of zero would mean every observed count exactly equals its expected count.

For an R × C contingency table, the degrees of freedom are df = (R − 1)(C − 1), where R is the number of rows and C is the number of columns. For a 2×2 table: df = 1. For a 2×3 table: df = 2. For a 3×4 table: df = 6. This formula comes from the number of free parameters in the table after the marginal totals are fixed.

The upper-tail probability P(X ≥ χ²_observed) is the probability of obtaining a chi-square statistic at least as large as the observed value, assuming the null hypothesis is true. This is the p-value for most standard chi-square tests (goodness-of-fit, independence, homogeneity). Larger observed statistics produce smaller p-values, which represent stronger evidence against H₀.

As degrees of freedom increase, the shape becomes increasingly symmetric and bell-like, approaching a normal distribution with mean k and variance 2k. A practical rule of thumb often cited in textbooks is that the normal approximation becomes reasonable around df = 30 or higher, but this is not an exact threshold. The chi-square distribution always remains bounded at zero, unlike the normal distribution, which extends across all real numbers.

Both distributions are non-negative and right-skewed at low degrees of freedom. An F-distributed variable is the ratio of two independent chi-square variables, each divided by their respective degrees of freedom: F(d₁, d₂) = [χ²(d₁)/d₁] / [χ²(d₂)/d₂]. This relationship connects ANOVA, regression F-tests, and chi-square variance tests within a unified theoretical framework.

Yes, for an upper-tail chi-square test with fixed degrees of freedom, a larger observed statistic always produces a smaller p-value. The upper-tail area P(X ≥ χ²) decreases as χ² increases. This is why chi-square tests treat large statistics as evidence against the null hypothesis — greater observed departures from expected values produce larger statistics and smaller p-values.

Fisher's exact test is an alternative to the chi-square test of independence that does not rely on a large-sample approximation. It computes the exact probability of the observed table and all more extreme tables, given fixed marginal totals. It is particularly useful when expected cell counts are small (say, below 5), the overall sample size is small, or when you want an exact result rather than an approximation. See our Fisher's exact test guide for detailed worked examples.

The mode is max(k − 2, 0). For df = 1, the mode is 0, meaning the distribution peaks at zero. For df = 2, the mode is still 0. For df ≥ 3, the mode is k − 2, which is positive and moves right as df increases. You can verify this by observing the peak of the curve in the visualizer above as you change the df slider.

Explore More on Statistics Fundamentals

Learn more about related concepts and tests at Statistics Fundamentals, your complete resource for statistics education and tools.

External references:
Pearson, K. (1900). On the criterion that a given system of deviations from the probable in the case of a correlated system of variables is such that it can be reasonably supposed to have arisen from random sampling. Philosophical Magazine, 50, 157–175. — The original publication introducing what became the chi-square goodness-of-fit test.

NIST/SEMATECH e-Handbook of Statistical Methods. itl.nist.gov/div898/handbook/ — A comprehensive public resource on statistical distributions and tests.

Agresti, A. (2002). Categorical Data Analysis (2nd ed.). Wiley. — The standard reference for chi-square tests in contingency table analysis.