Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools


Contingency Tables



How to read: The main table shows joint probabilities P(A∩B) in each cell. Row and column totals show marginal probabilities. The four tables on the right show all conditional probability distributions with their calculations. Click any conditional probability to highlight the corresponding cells in the main table.

Joint Probability Table

BBcTotal
A
0.4200
P(A ∩ B)
0.1800
P(A ∩ Bc)
0.6000
Ac
0.1200
P(Ac ∩ B)
0.2800
P(Ac ∩ Bc)
0.4000
Total0.54000.46001.0000
No selection made. Click any cell in the main table to see its joint probability explanation, or click any row in the conditional panels to understand how probabilities change when conditioning on known information.
Learn more about the 2×2 table · comparing all four

Conditional on A

Click rows to highlight paths
P(B|A) = P(A∩B) / P(A) = 0.42 / 0.600.7000
P(Bc|A) = P(A∩Bc) / P(A) = 0.18 / 0.600.3000
Total1.0000

Conditional on Ac

Click rows to highlight paths
P(B|Ac) = P(Ac∩B) / P(Ac) = 0.12 / 0.400.3000
P(Bc|Ac) = P(Ac∩Bc) / P(Ac) = 0.28 / 0.400.7000
Total1.0000

Conditional on B

Click rows to highlight paths
P(A|B) = P(A∩B) / P(B) = 0.42 / 0.540.7778
P(Ac|B) = P(Ac∩B) / P(B) = 0.12 / 0.540.2222
Total1.0000

Conditional on Bc

Click rows to highlight paths
P(A|Bc) = P(A∩Bc) / P(Bc) = 0.18 / 0.460.3913
P(Ac|Bc) = P(Ac∩Bc) / P(Bc) = 0.28 / 0.460.6087
Total1.0000





Getting Started with Contingency Tables

This interactive tool provides four different contingency table sizes to explore probability relationships between two categorical variables. Use the tabs at the top to switch between 2×2, 2×3, 2×4, and 3×3 configurations.

Each table displays three types of probability information simultaneously. The main grid shows joint probabilities in the interior cells, representing P(A ∩ B) for each combination of outcomes. The row and column totals display marginal probabilities, showing P(A) and P(B) individually. The surrounding panels show conditional probability distributions calculated from the joint and marginal values.

The layout follows a consistent pattern across all table sizes. On the left side, you see the joint probability table with clickable cells. On the right side, conditional probability panels show how probability distributes when you condition on different events. Click any cell or conditional row to highlight the mathematical relationship between joint and conditional probabilities.

Using the 2×2 Interactive Table

The 2×2 table is the only configuration with adjustable parameters, making it ideal for experimenting with probability relationships. Three sliders control the entire probability structure:

• P(A) sets the marginal probability of event A occurring. Moving this slider changes how probability mass distributes between row A and row Aᶜ.

• P(B|A) sets the conditional probability of B given A has occurred. This determines how the A row splits between columns B and Bᶜ.

• P(B|Aᶜ) sets the conditional probability of B given A has not occurred. This determines how the Aᶜ row splits between columns.

As you adjust any slider, all six joint probabilities, four marginal probabilities, and eight conditional probabilities recalculate instantly. Try setting P(B|A) equal to P(B|Aᶜ) and observe what happens to the conditional distributions—this demonstrates independence between events A and B.

Reading the Joint Probability Table

The central table displays joint probabilities P(A ∩ B) in each interior cell. These values represent the probability that both events occur together. Each cell shows two pieces of information: the numerical probability value and the notation identifying which intersection it represents.

Click any cell to highlight it with a distinct color. The highlighting helps you track that specific joint probability as it appears in conditional calculations on the right side. Each cell has a unique color that carries through to the conditional panels, making it easy to trace mathematical relationships visually.

The joint probabilities follow fundamental constraints from the probability axioms. All interior cells must sum to exactly 1.0000, representing the complete sample space. No cell can be negative, and no cell can exceed 1. In the 2×2 table, you can verify these constraints as you adjust the sliders—the tool maintains valid probability distributions automatically.

Understanding joint probability cells is essential because they serve as numerators in all conditional probability calculations. The formula P(AB)=P(AB)/P(B)P(A|B) = P(A \cap B) / P(B) uses the joint probability from the appropriate cell divided by the relevant marginal total.

Understanding Marginal Probabilities

Marginal probabilities appear in the "Total" row and column of each table. These values represent the probability of a single event regardless of the other variable's outcome.

Row totals show P(A), P(Aᶜ), or P(Aᵢ) for multi-row tables. Each row total equals the sum of all joint probabilities in that row. For example, P(A) = P(A ∩ B₁) + P(A ∩ B₂) + ... for all B categories.

Column totals show P(B), P(Bᶜ), or P(Bⱼ) for multi-column tables. Each column total equals the sum of all joint probabilities in that column. For example, P(B₁) = P(A₁ ∩ B₁) + P(A₂ ∩ B₁) + ... for all A categories.

The marginal probabilities serve as denominators in conditional probability formulas. When you click a conditional probability row in the right panels, the tool highlights both the numerator (joint cell) and denominator (marginal total) so you can see exactly which values produce the conditional probability.

Row marginals must sum to 1, and column marginals must sum to 1. This reflects the requirement that the outcomes for each variable form a complete partition of possibilities.

Exploring Conditional Probability Panels

The right side of each table displays conditional probability distributions organized by conditioning event. Each panel answers the question: "Given that we know one event occurred, how does probability distribute across the other variable?"

For the 2×2 table, four panels show:

• Conditional on A shows P(B|A) and P(Bᶜ|A)

• Conditional on Aᶜ shows P(B|Aᶜ) and P(Bᶜ|Aᶜ)

• Conditional on B shows P(A|B) and P(Aᶜ|B)

• Conditional on Bᶜ shows P(A|Bᶜ) and P(Aᶜ|Bᶜ)

Click any row in a conditional panel to see three things highlighted simultaneously: the joint probability cell (numerator), the marginal probability (denominator), and the formula breakdown showing the exact calculation.

For larger tables (2×3, 2×4, 3×3), expand the Row Explanations accordion in each panel to see what each conditional probability represents. The accordions help manage the increased complexity without cluttering the display.

Each conditional distribution sums to exactly 1.0000, verified in the "Total" row of each panel. This reflects the requirement that conditional probabilities form valid probability distributions.

Comparing Different Table Sizes

Each table size serves different analytical purposes. Choose the configuration that matches your problem structure:

The 2×2 table works for two binary events (yes/no, success/failure, positive/negative). The interactive sliders make this ideal for learning how parameters affect probability relationships. Medical testing scenarios (disease/no disease, test positive/negative) fit this format perfectly.

The 2×3 table applies when one variable is binary and the other has three categories. Examples include treatment group (control/experimental) versus outcome (improved/unchanged/worsened), or gender versus education level (high school/college/graduate).

The 2×4 table handles one binary variable and one with four categories. Examples include employed/unemployed versus income quartile, or product defective/non-defective versus manufacturing shift.

The 3×3 table covers situations where both variables have three categories. This shows the full complexity of multi-category relationships. Examples include satisfaction level (low/medium/high) versus age group (young/middle/senior), or product quality versus supplier.

Larger tables demonstrate that the same mathematical principles apply regardless of size—joint cells sum to marginals, and conditional probabilities equal joint divided by marginal.

The 2×2 Table: Two Events and Their Complements

The default view crosses one event AA against one event BB, giving four joint probabilities. With the tool's parameters — P(A)=0.6P(A) = 0.6, P(BmidA)=0.7P(B mid A) = 0.7, P(BmidAc)=0.3P(B mid A^c) = 0.3 — the body reads

P(AcapB)=0.42P(A cap B) = 0.42, P(AcapBc)=0.18P(A cap B^c) = 0.18, P(AccapB)=0.12P(A^c cap B) = 0.12, P(AccapBc)=0.28P(A^c cap B^c) = 0.28

and the four cells sum to 1, as the frozen table's grand total confirms.
2×2 contingency tableBBᶜtotalA0.4200.1800.60Aᶜ0.1200.2800.40total0.540.461.00
2×2 table, frozen

Four joint probabilities summing to 1, with P(A) = 0.6 and P(Aᶜ) = 0.4 down the right margin and P(B) = 0.54, P(Bᶜ) = 0.46 along the bottom.


The 2×3 Table: One Event Against Three Outcomes

Widening the second variable to three mutually exclusive outcomes gives six joint cells. The tool uses P(A)=0.6P(A) = 0.6 with conditionals 0.50.5, 0.30.3 and the remainder 0.20.2 across B1,B2,B3B_1, B_2, B_3, and 0.30.3, 0.40.4, 0.30.3 in the AcA^c row.

Column totals come out 0.420.42, 0.340.34 and 0.240.24, and the six cells still sum to 1.
2×3 contingency tableB₁B₂B₃totalA0.3000.1800.1200.60Aᶜ0.1200.1600.1200.40total0.420.340.241.00
2×3 table, frozen

Six cells. The B column totals read 0.42, 0.34, 0.24 - and the complement of B₁ is now two columns rather than one.


The 2×4 Table: Four Outcomes

A fourth outcome column extends the same pattern to eight cells. The conditionals in the AA row are 0.30.3, 0.250.25, 0.250.25 and the remaining 0.20.2; the AcA^c row runs 0.20.2, 0.350.35, 0.250.25, 0.20.2.

Column totals are 0.260.26, 0.290.29, 0.250.25 and 0.200.20 — and again the grid sums to 1.
2×4 contingency tableB₁B₂B₃B₄totalA0.1800.1500.1500.1200.60Aᶜ0.0800.1400.1000.0800.40total0.260.290.250.201.00
2×4 table, frozen

Eight cells with column totals 0.26, 0.29, 0.25, 0.20. Wide enough that the marginals have to be computed rather than eyeballed.


The 3×3 Table: Both Variables Partitioned

The last shape partitions both variables into three, giving nine joint cells. The tool uses P(A1)=0.3P(A_1) = 0.3, P(A2)=0.4P(A_2) = 0.4 and the remaining P(A3)=0.3P(A_3) = 0.3, with a row of conditionals for each.

Row totals are 0.300.30, 0.400.40, 0.300.30; column totals 0.340.34, 0.350.35, 0.300.30; grand total 1.
3×3 contingency tableB₁B₂B₃totalA₁0.1200.1050.0750.30A₂0.1200.1600.1200.40A₃0.1050.0900.1050.30total0.340.350.301.00
3×3 table, frozen

Nine cells with both variables partitioned three ways. Row totals 0.30, 0.40, 0.30; column totals 0.34, 0.35, 0.30; grand total 1.


What is a Contingency Table?

A contingency table (also called a cross-tabulation or two-way table) organizes the joint distribution of two categorical variables into a grid format. Each cell represents the probability or frequency of a specific combination of outcomes from both variables.

In probability contexts, contingency tables display three interconnected quantities: joint probabilities in interior cells, marginal probabilities in row and column totals, and conditional probabilities derivable from these values. The table structure makes relationships between these probability types visually apparent and computationally straightforward.

Contingency tables originated in statistical analysis for studying associations between categorical variables. In probability theory, they provide a complete specification of the joint distribution for discrete variables with finite outcome spaces. Any question about probabilities involving the two variables can be answered directly from the table.

For comprehensive coverage of probability table concepts and applications, see the joint probability and conditional probability theory pages.

Joint, Marginal, and Conditional Probabilities

Three probability types appear in every contingency table, related by fundamental formulas:

Joint probability P(A ∩ B) measures the likelihood that both events A and B occur together. These values fill the interior cells of the table. Joint probabilities are symmetric: P(A ∩ B) = P(B ∩ A).

Marginal probability P(A) or P(B) measures the likelihood of a single event regardless of the other variable. Marginals are computed by summing joint probabilities: P(A) = Σ P(A ∩ Bⱼ) over all B categories.

Conditional probability P(A|B) measures the likelihood of A given that B has occurred. The definition formula connects all three types:

P(AB)=P(AB)P(B)P(A|B) = \frac{P(A \cap B)}{P(B)}


This formula shows why clicking a conditional row highlights both a joint cell (numerator) and a marginal total (denominator). The visual highlighting traces exactly how conditional probabilities derive from the table's fundamental values.

For detailed theory on these probability types, see conditional probability and joint probability.

Connection to Bayes' Theorem

Contingency tables provide a visual demonstration of Bayes' theorem in action. The theorem relates conditional probabilities in opposite directions:

P(AB)=P(BA)P(A)P(B)P(A|B) = \frac{P(B|A) \cdot P(A)}{P(B)}


In the table, this relationship becomes visible through the highlighting system. The same joint probability cell P(A ∩ B) appears as a numerator in two different conditional calculations: P(A|B) conditions on B, while P(B|A) conditions on A.

Try this experiment in the 2×2 table: click on P(A|B) in the "Conditional on B" panel, then click P(B|A) in the "Conditional on A" panel. Both highlight the same green joint cell P(A ∩ B), but with different marginal denominators. This demonstrates how Bayes' theorem "flips" the conditioning by using different denominators.

The table also shows the law of total probability visually. Each marginal P(B) equals the sum of joint probabilities in that column, which equals P(B|A)·P(A) + P(B|Aᶜ)·P(Aᶜ). This sum appears in Bayes' theorem's denominator.

For complete coverage of Bayesian reasoning, see the Bayes theorem theory page and Bayes calculator.