Skip to main content
ExplainerContingency Tables· Updated · 4 min read· in Data & Analysis

Why Contingency Tables Multiply Marginal Totals to Find Expected Frequencies

Under the mathematical assumption that two categorical variables are completely independent, the expected count for any cell in a cross-tabulation is calculated by multiplying its row and column totals and dividing by the overall sample size.

By Viktoria Sokolova

Share this story

Listen

In short

  1. Expected frequencies represent what data would look like if two variables were completely unrelated.
  2. The calculation multiplies a cell's row total by its column total, then divides by the grand total.
  3. This formula is an algebraic simplification of the multiplication rule for independent probabilities.

The binding constraint for calculating an expected frequency is the assumption of absolute statistical independence. For the mathematics to work, the probability of an observation falling into a specific row must be completely unaffected by which column it belongs to. If that condition holds, the expected count in any cell of a contingency table is simply the product of its marginal totals divided by the grand total.[1][6]

This calculation forms the engine of the chi-square test of independence, a statistical method developed by Karl Pearson in 1900 and used across disciplines from epidemiology to marketing. Before researchers can determine if a relationship exists between two categorical variables—such as a patient's treatment group and their recovery status—they must first establish exactly what the data would look like if no relationship existed at all.[1][2]

A contingency table, or cross-tabulation, organizes data into a grid. In a standard 2x2 table, there are 4 individual cells. The "marginal totals" are the sums of each row and column, appearing in the margins of the table, while the "grand total" is the overall sample size of the dataset.[3][4]

To find the expected frequency for a specific cell, researchers multiply that cell's row total by its column total, then divide by the grand total. For example, if a clinical trial includes 100 total patients, with 50 receiving a new drug and 40 experiencing a specific side effect, the expected frequency of patients both receiving the drug and experiencing the side effect under the assumption of independence is (50 × 40) / 100, or exactly 20 patients.[4][5]

The expected frequency formula simplifies the joint probability of two independent events.

The mechanics behind this formula rely on the fundamental multiplication rule of probability. When two events are independent, the probability of both occurring simultaneously is the product of their individual probabilities.[2][3]

The probability of an observation landing in a specific row is the row total divided by the grand total. Similarly, the probability of it landing in a specific column is the column total divided by the grand total.[3]

Multiplying these two marginal probabilities yields the joint probability for that specific cell. To convert that theoretical probability back into an expected count, it must be multiplied by the grand total.[1][6]

Mathematically, this is expressed as: (Row Total / Grand Total) × (Column Total / Grand Total) × Grand Total. When simplified, one of the grand totals in the denominator cancels out the grand total in the numerator, leaving the standard formula.[5][6]

This elegant algebraic simplification is why researchers do not need to calculate individual probabilities for every cell. As the National Institute of Standards and Technology documentation notes, "The expected frequency for each cell is computed as the product of the row and column marginal totals divided by the grand total."[2]

Once the expected frequencies are calculated for every cell in the table, they are compared against the actual observed frequencies. The difference between the observed and expected counts forms the basis of the chi-square statistic, which squares the differences and divides by the expected counts to standardize the variance.[1][2]

The chi-square test measures how far observed data deviates from the expected baseline.

If the observed counts closely match the expected counts, the deviation is small, suggesting that the variables are indeed independent. If the observed counts diverge significantly from the expected baseline, it indicates a statistical relationship that is unlikely to have occurred by chance.[1][3]

However, this mathematical framework has strict limitations. The calculation assumes that the sample is randomly drawn and that the observations are mutually exclusive, meaning no single subject can be counted in more than one cell.[3][5]

Furthermore, the reliability of the subsequent chi-square test degrades if the expected frequencies are too small. A widely accepted rule of thumb dictates that the expected frequency in any given cell should be at least 5 to ensure the test statistic accurately approximates a chi-square distribution.[1][5]

When expected counts fall below this threshold, researchers must either combine categories to increase the marginal totals or abandon the chi-square test in favor of alternatives like Fisher's exact test, published in 1922, which calculates exact probabilities rather than relying on approximations.[2][3]

The dimensions of the table also dictate the degrees of freedom, calculated as the number of rows minus 1 multiplied by the number of columns minus 1. For a 3x4 table, this yields 6 degrees of freedom, which determines the exact shape of the chi-square distribution used to evaluate whether the deviations from the expected frequencies are statistically significant.[4][5]

Key terms

Contingency Table
A grid used in statistics to summarize the relationship between two or more categorical variables.
Marginal Total
The sum of the counts for a specific row or column, found in the margins of a contingency table.
Grand Total
The overall sample size, representing the sum of all observations in the entire table.
Null Hypothesis
The baseline assumption that there is no relationship or interaction between the variables being studied.

Where opinion splits

Frequentist Statisticians

View expected frequencies as the crucial mathematical representation of the null hypothesis.

In the frequentist framework, expected frequencies are not merely a computational step; they are the physical manifestation of the null hypothesis. By calculating exactly what the data should look like if chance alone dictated the distribution, statisticians create a rigid mathematical baseline. Any deviation from this baseline is then quantified to determine if the observed reality is too extreme to have occurred in a universe where the variables are independent.

Data Scientists

Utilize expected frequencies in feature selection algorithms to identify predictive variables.

For modern machine learning practitioners, contingency tables and expected frequencies are often automated away into feature selection algorithms. When building classification models, data scientists use chi-square tests to filter out categorical features that are independent of the target variable. If a feature's observed frequencies closely match its expected frequencies across the target classes, the feature provides no predictive signal and is dropped from the model to reduce dimensionality.

Frequentist Statisticians 40%Data Scientists 30%Quality Control Engineers 30%
Frequentist Statisticians
View expected frequencies as the crucial mathematical representation of the null hypothesis, providing the baseline against which observed data is tested.
Data Scientists
Utilize expected frequencies in feature selection algorithms to identify which categorical variables carry the most predictive power for machine learning models.
Quality Control Engineers
Apply these calculations to manufacturing contingency tables to determine if defect rates are independent of specific production lines or shifts.

Perspectives this story doesn't cover

  • Bayesian Statisticians
  • Survey Methodologists

Sources

Source coverage

6 outlets

3 viewpoints surfaced

Frequentist Statisticians 40%Data Scientists 30%Quality Control Engineers 30%
  1. [1]PMCFrequentist Statisticians

    The Chi-square test of independence

    Read on PMC →
  2. [2]NISTQuality Control Engineers

    CHI-SQUARE INDEPENDENCE TEST

    Read on NIST →
  3. [3]University of VermontFrequentist Statisticians

    CHI-SQUARE TEST - ANALYSIS OF CONTINGENCY TABLES

    Read on University of Vermont →
  4. [4]Statistics How ToData Scientists

    Expected Frequency: Definition, Formula, Calculation

    Read on Statistics How To →
  5. [5]bookdown.orgData Scientists

    Chapter 27 Contingency tables

    Read on bookdown.org →
  6. [6]Factlen Editorial Team

    Synthesis by Factlen editorial team

    Read on Factlen Editorial Team →
Listen

Comments

Stay informed

Every angle. Every day.

Get Data & Analysis stories with full source coverage and perspective breakdowns, free every day.