Conditional Probability Calculator
Use this Conditional Probability Calculator to find \(P(A|B)\), \(P(B|A)\), \(P(A \cap B)\), \(P(A \cup B)\), independence, Bayes’ theorem probability, complementary probabilities, two-way table probabilities, diagnostic-test probability, false positive probability, and step-by-step probability explanations. It is built for statistics students, AP Statistics, IB Math, GCSE/IGCSE, college probability, data science, decision science, risk analysis, and real-world probability reasoning.
Interactive Conditional Probability Calculator
Calculate \(P(A|B)\)
Find Intersection from Conditional Probability
Calculate \(P(A \cup B)\)
Bayes’ Theorem Calculator
Two-Way Table Conditional Probability
Enter counts for a \(2 \times 2\) table. The calculator computes joint, marginal, and conditional probabilities.
Diagnostic Test Probability
Useful for medical-test style probability, spam filters, fraud detection, quality control, and classification models.
Independence Check
Result
Conditional Probability Visual
Conditional Probability Calculator: Complete Guide
Conditional probability is one of the most important ideas in probability, statistics, data science, risk analysis, medical testing, machine learning, decision theory, and everyday reasoning. It answers a specific question: how likely is event \(A\), given that event \(B\) is already known to have occurred? This is different from the ordinary probability of \(A\), because new information can change the sample space and therefore change the probability.
This Conditional Probability Calculator is designed to handle common probability tasks in one place. You can calculate \(P(A|B)\), find \(P(A \cap B)\), calculate \(P(A \cup B)\), apply Bayes’ theorem, test whether events are independent, work from a two-way table, and solve diagnostic-test style probability problems. The tool gives the final answer and also shows the formula and step-by-step work so students can understand the reasoning instead of only copying a result.
What Is Conditional Probability?
Conditional probability is the probability that one event occurs under the condition that another event has already occurred. It is written as:
This is read as “the probability of \(A\) given \(B\).” It does not mean \(P(A)\) divided by \(P(B)\). It means the probability of \(A\) inside the restricted world where \(B\) is true.
The numerator \(P(A\cap B)\) is the probability that both \(A\) and \(B\) happen. The denominator \(P(B)\) is the probability that \(B\) happens. By dividing the overlap by \(P(B)\), we measure what fraction of event \(B\) also belongs to event \(A\).
Understanding “Given” in Probability
The word “given” is the key to conditional probability. If you are told that \(B\) has happened, all outcomes outside \(B\) are no longer relevant. The sample space changes from the full universe of outcomes to only the outcomes inside \(B\). Then you ask how much of that new sample space is also in \(A\).
For example, suppose a school has students who take math, science, both, or neither. If you ask, “What is the probability a student takes math?” you consider all students. But if you ask, “What is the probability a student takes math given that the student takes science?” you only consider science students. The denominator changes.
Conditional Probability Formula
The standard conditional probability formula is:
The condition \(P(B)>0\) is required because division by zero is undefined. If \(B\) has probability zero, there is no meaningful ordinary conditional probability using this elementary formula.
Example 1: Basic Conditional Probability
Suppose:
Then:
So the probability of \(A\) given \(B\) is \(0.60\), or \(60\%\).
Finding the Intersection
If \(P(A|B)\) and \(P(B)\) are known, you can rearrange the conditional probability formula to find the intersection:
For example, if:
Then:
Union Probability
The union of two events, \(A\cup B\), means \(A\) happens, or \(B\) happens, or both happen. The formula is:
The subtraction is necessary because \(P(A)+P(B)\) counts the overlap twice. The overlap \(P(A\cap B)\) must be subtracted once.
Example 2: Union
Suppose:
Then:
So the probability that \(A\) or \(B\) occurs is \(0.57\), or \(57\%\).
Bayes’ Theorem
Bayes’ theorem is one of the most powerful uses of conditional probability. It allows us to reverse a conditional probability. If we know \(P(B|A)\), \(P(A)\), and \(P(B)\), we can find \(P(A|B)\).
Bayes’ theorem is used in medical testing, spam detection, legal reasoning, fraud detection, machine learning, quality control, weather forecasting, search engines, recommendation systems, and risk assessment.
Example 3: Bayes’ Theorem
Suppose:
Then:
The posterior probability \(P(A|B)\) is \(0.36\), or \(36\%\).
Independence and Conditional Probability
Events \(A\) and \(B\) are independent if knowing that \(B\) occurred does not change the probability of \(A\). In formula form:
Another equivalent test is:
If this equality holds, the events are independent. If it does not hold, the events are dependent.
Example 4: Independence Check
Suppose:
If the events are independent, then:
If the actual intersection is \(0.135\), the events are independent. If the actual intersection is different, the events are not independent.
Two-Way Tables
Conditional probability is often easier when data is shown in a two-way table. A two-way table counts how many observations fall into combinations of two categories. For example, a table may show how many people have event \(A\), how many have event \(B\), how many have both, and how many have neither.
| \(B\) | \(\overline B\) | Total | |
|---|---|---|---|
| \(A\) | \(A\cap B\) | \(A\cap \overline B\) | \(A\) |
| \(\overline A\) | \(\overline A\cap B\) | \(\overline A\cap \overline B\) | \(\overline A\) |
| Total | \(B\) | \(\overline B\) | Total |
From a table, \(P(A|B)\) is:
Diagnostic Test Probability
Diagnostic-test probability is a common real-world application of conditional probability. It applies not only to medical testing but also to spam filters, machine learning classifiers, fraud detection, manufacturing inspection, and screening systems.
Important terms include:
- Prevalence: \(P(D)\), the probability a person or item truly has the condition.
- Sensitivity: \(P(+|D)\), the probability of a positive test given the condition is present.
- Specificity: \(P(-|\overline D)\), the probability of a negative test given the condition is absent.
- False positive rate: \(P(+|\overline D)=1-\text{specificity}\).
- Positive predictive value: \(P(D|+)\), the probability the condition is truly present given a positive test.
Why Base Rates Matter
Base rate means the prior probability of an event before new evidence. In diagnostic testing, the base rate is prevalence. Even if a test has high sensitivity and specificity, the probability of actually having the condition after a positive test can be lower than expected when prevalence is low. This is called the base-rate effect.
For example, if a condition is rare, many positive results may come from false positives unless the test is extremely specific. Conditional probability helps avoid the common mistake of confusing \(P(+|D)\) with \(P(D|+)\).
Common Mistake: Reversing Conditional Probability
One of the most common errors is assuming:
This is usually false. The probability of being a student given that someone is in a classroom is not necessarily the same as the probability of being in a classroom given that someone is a student. These are different questions with different denominators.
Complement Rules
The complement of event \(A\) is the event that \(A\) does not occur. It is written as \(\overline A\), \(A^c\), or “not A.”
Conditional complements also work:
If \(P(A|B)=0.60\), then:
Mutually Exclusive Events vs Independent Events
Mutually exclusive events cannot happen at the same time. If \(A\) and \(B\) are mutually exclusive:
Independent events do not affect each other’s probabilities:
Mutually exclusive events are usually not independent unless one event has probability zero. This is because if \(B\) happens and \(A\) cannot happen with \(B\), then knowing \(B\) happened changes the probability of \(A\).
Conditional Probability in Statistics Courses
Conditional probability appears in school and college statistics in many forms. Students use it in Venn diagrams, two-way tables, probability trees, contingency tables, diagnostic testing, independence checks, Bayes’ theorem, expected value, and inference contexts. In AP Statistics, IB Mathematics, GCSE/IGCSE probability, A-Level statistics, and introductory college statistics, conditional probability is a core skill because it connects raw data with reasoning.
How to Use This Conditional Probability Calculator
- Select the calculation mode: Conditional, Intersection, Union, Bayes, Two-Way Table, Diagnostic Test, or Independence.
- Enter probabilities as decimals or percentages depending on the selected format.
- For table mode, enter counts in the four cells of the \(2 \times 2\) table.
- Click the calculate button.
- Review the result, complement, formula, and step-by-step explanation.
- Use the visual Venn diagram to understand how the intersection relates to the condition.
Formula Table
| Concept | Formula | Meaning |
|---|---|---|
| Conditional probability | \(P(A|B)=\frac{P(A\cap B)}{P(B)}\) | Probability of \(A\), restricted to event \(B\). |
| Intersection | \(P(A\cap B)=P(A|B)P(B)\) | Probability both events happen. |
| Union | \(P(A\cup B)=P(A)+P(B)-P(A\cap B)\) | Probability \(A\), \(B\), or both happen. |
| Bayes’ theorem | \(P(A|B)=\frac{P(B|A)P(A)}{P(B)}\) | Reverse a conditional probability. |
| Independence | \(P(A\cap B)=P(A)P(B)\) | Check whether events affect each other. |
Frequently Asked Questions
What is conditional probability?
Conditional probability is the probability that event \(A\) occurs given that event \(B\) has already occurred.
What is the formula for \(P(A|B)\)?
The formula is \(P(A|B)=\frac{P(A\cap B)}{P(B)}\), where \(P(B)>0\).
Is \(P(A|B)\) the same as \(P(B|A)\)?
No. These are usually different probabilities because they use different conditions and different denominators.
How do I calculate \(P(A\cap B)\)?
Use \(P(A\cap B)=P(A|B)P(B)\), or if events are independent, use \(P(A\cap B)=P(A)P(B)\).
How do I calculate \(P(A\cup B)\)?
Use \(P(A\cup B)=P(A)+P(B)-P(A\cap B)\).
What does independence mean?
Events are independent if knowing one event occurred does not change the probability of the other event.
What is Bayes’ theorem?
Bayes’ theorem calculates \(P(A|B)\) from \(P(B|A)\), \(P(A)\), and \(P(B)\).
Can I use counts instead of probabilities?
Yes. Use the Two-Way Table mode to enter counts. The calculator converts counts into probabilities.
What is a false positive rate?
The false positive rate is \(P(+|\overline D)=1-\text{specificity}\).
Why is conditional probability important?
It helps update probability after new information and is used in statistics, medical testing, risk analysis, machine learning, and decision making.
