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

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.

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.

Related Tools and Concepts

Contingency tables connect to many probability concepts and visualization tools available on this site.

Theoretical Foundations


Conditional Probability covers complete theory of P(A|B), independence, and conditioning rules

Joint Probability provides detailed coverage of joint distributions for multiple variables

Bayes Theorem explains the formula connecting P(A|B) to P(B|A) with derivations and applications

Independence describes when P(A|B) = P(A), meaning conditioning provides no information

Related Visualizations


Venn Diagrams visualize conditional probability through overlapping regions

Tree Diagrams show sequential conditioning as branching paths

Calculators


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

Bayes Theorem Calculator applies Bayes' formula with prior and likelihood inputs

Joint Probability Calculator works with joint distributions and marginalization