Probability

Conditional Probability Calculator

Use this conditional probability calculator to find P(A|B) or P(B|A) from probabilities, counts, or a 2×2 table. Enter your values and click Calculate to get the answer with a clear, step-by-step solution.

Enter a decimal from 0 to 1.
Enter the probability of the conditioning event B.

Example results are shown automatically. After changing the values, click Calculate to update the results.


How to Use the Conditional Probability Calculator

Calculating conditional probability depends entirely on the format of the data you're given. This calculator has three distinct modes to match your data type:

1. Probabilities Mode

Use this mode if you have already been given the probabilities of the events (e.g., P(A) = 0.5, P(B) = 0.6). You will need the joint probability (the probability of both occurring together) and the probability of the conditioning event.

2. Counts (Frequencies) Mode

Use this mode if you know the exact number of times the events occurred, rather than their probabilities. You just need to know the number of times both events occurred together, and the total number of times the conditioning event occurred.

3. 2×2 Table Mode

Use this mode if you have data organized in a contingency table (or a cross-tabulation table). Simply fill in the four inner frequencies (A and B, A and Not B, etc.). The calculator will automatically sum up the row totals, column totals, and the grand total, and extract the correct numbers to find your conditional probability.

What is Conditional Probability?

Conditional probability is the probability of an event occurring given that another event has already occurred. It is a way of narrowing down the sample space based on new information.

It is denoted as P(A|B), which is read aloud as "The probability of A given B".

For example, what is the probability that a randomly selected person likes to play golf (Event A)? Let's say it's 10%. Now, what is the probability that a person likes to play golf, given that we already know they are retired (Event B)? That probability is likely much higher than 10%. The new condition (being retired) drastically changed the probability of the event.

Conditional Probability Formula

When working with probabilities, the formula for conditional probability is:

P(A|B) = P(A ∩ B) / P(B)
  • P(A|B): The probability of A given B.
  • P(A ∩ B): The joint probability of A and B (the probability that both occur).
  • P(B): The marginal probability of event B.

How to Calculate Conditional Probability (Probabilities)

If you are given probabilities, you can plug them directly into the formula.

Example: Rain and Traffic

The probability that it rains and there is heavy traffic is 0.15 (P(A ∩ B) = 0.15). The probability that it rains on any given day is 0.25 (P(B) = 0.25).

What is the probability of heavy traffic given that it is raining?

Step 1: Apply the formula

P(Heavy Traffic | Rain) = P(Heavy Traffic ∩ Rain) / P(Rain)

P(Heavy Traffic | Rain) = 0.15 / 0.25

P(Heavy Traffic | Rain) = 0.60

How to Calculate Conditional Probability (Counts/Frequencies)

If you are given raw counts instead of probabilities, the logic is identical, but you use the number of occurrences (n) instead of probabilities (P). This works because the total sample space size cancels out in the division.

P(A|B) = n(A ∩ B) / n(B)

How to Find Conditional Probability from a 2×2 Table

A 2×2 contingency table is one of the easiest ways to calculate conditional probability because it organizes all the counts for you.

Let's say we have the following table showing 100 students, broken down by gender and whether they play sports:

Plays SportsNo SportsTotal
Boys302050
Girls104050
Total4060100

Question: What is the probability a student plays sports given that they are a Boy?

  • Condition: The student must be a boy. Looking at the table, the total number of boys is 50. (This is our denominator).
  • Intersection: How many of those boys play sports? Looking at the "Boys" row and "Plays Sports" column, the intersection is 30. (This is our numerator).
  • Result: P(Sports | Boy) = 30 / 50 = 0.60

Conditional Probability vs Joint Probability

It's easy to confuse these two concepts.

  • Joint Probability P(A ∩ B): The probability that both A and B occur together out of the entire sample space. (e.g., The probability of drawing a card that is both red AND a king from a full 52-card deck).
  • Conditional Probability P(A|B): The probability of A occurring, restricting the sample space ONLY to those where B has already occurred. (e.g., The probability of drawing a king, given that you already know the card you drew is red).

Dependent vs Independent Events in Probability

Conditional probability is directly tied to the concept of independence.

Independent Events: The occurrence of event B has absolutely no effect on the probability of event A. If A and B are independent, then P(A|B) = P(A).

Dependent Events: The occurrence of event B changes the probability of event A. If A and B are dependent, then P(A|B) ≠ P(A).

Frequently Asked Questions

No, usually not. P(A|B) asks for the probability of A out of the sub-group B. P(B|A) asks for the probability of B out of the sub-group A. They will only equal each other if the total probability of A equals the total probability of B.

If A and B are mutually exclusive, they cannot happen at the same time. This means their joint probability P(A ∩ B) is 0. Therefore, the conditional probability P(A|B) will also always be 0.

Bayes' Theorem is built directly upon the conditional probability formula. It expands the formula to allow you to calculate P(A|B) when you only know P(B|A) and the prior probabilities.