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
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.

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.

The Table at Its Opening Settings

The sliders start at P(A)=0.6P(A) = 0.6, P(BA)=0.7P(B \mid A) = 0.7 and P(BAc)=0.3P(B \mid A^c) = 0.3, giving the four joint cells 0.420.42, 0.180.18, 0.120.12 and 0.280.28.

Read across for the row marginals 0.600.60 and 0.400.40; read down for the column marginals 0.540.54 and 0.460.46. The grand total is exactly 11.
2×2 contingency tableBBᶜtotalA0.4200.1800.60Aᶜ0.1200.2800.40total0.540.461.00
The 2x2 table at P(A) = 0.6, P(B|A) = 0.7, P(B|not A) = 0.3

Cells 0.42 / 0.18 / 0.12 / 0.28, row totals 0.60 and 0.40, column totals 0.54 and 0.46, grand total exactly 1. P(B) = 0.54 is just a column sum.

The table and the tree are the same three numbers in two layouts, and each makes a different thing easy. The tree shows how the joints are *built* — multiply along a path. The table shows how the marginals are *recovered* — sum along a row or a column.

The column marginal is where the table earns its place. P(B)=0.42+0.12=0.54P(B) = 0.42 + 0.12 = 0.54 is the law of total probability, and in this layout it is not a formula at all, just the total of a column.

Both conditionals live here too, as the same cell over two different totals: P(BA)=0.420.60=0.7P(B \mid A) = \frac{0.42}{0.60} = 0.7 divides by its row, and P(AB)=0.420.54=0.7778P(A \mid B) = \frac{0.42}{0.54} = 0.7778 divides by its column. Bayes' theorem is the instruction to switch which total you divide by.

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.