Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools


Contingency Table Visualization

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

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




Visualizing Conditional Probability with Contingency Tables

This interactive 2×2 contingency table displays the complete probability relationship between two events. Three sliders control P(A), P(B|A), and P(B|Aᶜ), with all joint, marginal, and conditional probabilities updating in real time. Click any cell or conditional probability row to highlight the mathematical relationship.



Getting Started with the Contingency Table

This interactive 2×2 contingency table displays the complete probability relationship between two events A and B. The table organizes joint probabilities, marginal probabilities, and conditional probabilities in a single unified view.

The left side shows the main probability table with four interior cells (joint probabilities) and row/column totals (marginal probabilities). The right side displays four conditional probability panels showing P(B|A), P(B|Aᶜ), P(A|B), and P(A|Bᶜ).

Three sliders below the table control P(A), P(B|A), and P(B|Aᶜ). All other probabilities derive from these three inputs. Click any cell or conditional probability row to highlight the mathematical relationship between values.

Using the Probability Sliders

Three sliders control the entire probability structure:

• P(A) sets the marginal probability of event A. This determines the row totals—how probability splits between row A and row Aᶜ.

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

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

As you adjust any slider, all six interior cells and four marginal totals recalculate instantly. The conditional probability panels on the right also update. Try setting P(B|A) = P(B|Aᶜ) to see what happens—this creates independence between A and B.

Reading the Joint Probability Table

The 2×2 table interior contains four joint probabilities:

• P(A ∩ B) — upper left: probability both A and B occur
• P(A ∩ Bᶜ) — upper right: probability A occurs but B does not
• P(Aᶜ ∩ B) — lower left: probability B occurs but A does not
• P(Aᶜ ∩ Bᶜ) — lower right: probability neither occurs

Each cell has a distinct color for visual tracking. Click any cell to highlight it and see how it appears in conditional probability calculations on the right.

The four joint probabilities sum to exactly 1.0000, representing the complete sample space. The table displays this sum in the bottom-right total cell.

Understanding Marginal Probabilities

Marginal probabilities appear in the "Total" row and column:

Row totals (right side):
• P(A) — sum of joint probabilities in the A row
• P(Aᶜ) — sum of joint probabilities in the Aᶜ row

Column totals (bottom):
• P(B) — sum of joint probabilities in the B column
• P(Bᶜ) — sum of joint probabilities in the Bᶜ column

The relationship:

P(A)=P(AB)+P(ABc)P(A) = P(A \cap B) + P(A \cap B^c)


P(B)=P(AB)+P(AcB)P(B) = P(A \cap B) + P(A^c \cap B)


Row marginals sum to 1: P(A) + P(Aᶜ) = 1. Column marginals also sum to 1: P(B) + P(Bᶜ) = 1. Marginal probabilities serve as denominators in conditional probability formulas.

Exploring Conditional Probability Panels

Four panels on the right display conditional probability distributions:

Top row panels condition on A:
• P(B|A) and P(Bᶜ|A) — given A occurred, probability of B vs Bᶜ
• P(B|Aᶜ) and P(Bᶜ|Aᶜ) — given A did not occur, probability of B vs Bᶜ

Bottom row panels condition on B:
• P(A|B) and P(Aᶜ|B) — given B occurred, probability of A vs Aᶜ
• P(A|Bᶜ) and P(Aᶜ|Bᶜ) — given B did not occur, probability of A vs Aᶜ

Each conditional probability shows its formula breakdown. Click any row to highlight the numerator (joint cell) and denominator (marginal total) in the main table, visually confirming:

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

Clicking to Trace Calculations

The highlighting system reveals how conditional probabilities derive from the table:

Click a joint cell (e.g., P(A ∩ B)):
The cell highlights in its unique color. Look at the conditional panels to see where this joint probability appears as a numerator.

Click a conditional probability row (e.g., P(A|B)):
Three things highlight simultaneously:
• The joint probability cell (numerator)
• The marginal probability (denominator)
• The formula showing the division

This visualization demonstrates that conditional probability is always a ratio: the intersection divided by the condition. The same joint probability P(A ∩ B) appears in both P(A|B) (denominator P(B)) and P(B|A) (denominator P(A)).

Use the Clear Selection button to remove all highlighting.

Bayes' Theorem in the Table

The contingency table demonstrates Bayes' theorem visually. Compare P(A|B) with P(B|A):

Both use the same numerator P(A ∩ B), but different denominators:

P(AB)=P(AB)P(B)vsP(BA)=P(AB)P(A)P(A|B) = \frac{P(A \cap B)}{P(B)} \quad \text{vs} \quad P(B|A) = \frac{P(A \cap B)}{P(A)}


Bayes' theorem relates these:

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


Try this: click P(A|B), note which cells highlight. Then click P(B|A). Both highlight the same green joint cell but with different marginal denominators. This is Bayes' theorem in action—flipping the condition changes the denominator.

The table shows P(B) calculated via total probability: P(B) = P(A)·P(B|A) + P(Aᶜ)·P(B|Aᶜ), which appears in Bayes' formula's denominator.

Related Tools and Concepts

Contingency tables connect to several probability concepts and tools on this site:

Theory Pages:

Conditional Probability explains P(A|B) theory in depth

Bayes' Theorem covers reversing conditional probabilities

Joint Probability details probability of combined events

Independence describes when P(A|B) = P(A)

Other Visualizations:

Tree Diagrams show conditional probability as branching paths

Venn Diagrams display overlapping regions

Waffle Charts show proportions in grid format

Calculators:

Bayes' Theorem Calculator computes reverse conditionals

Conditional Probability Calculator calculates P(A|B) from inputs

Joint Probability Calculator works with joint distributions