Conditional Probability Calculator

Find conditional probability P(A | B) from the joint probability and P(B), solve for any value, test independence, and run Bayes' theorem with a contingency table.

https://hexacalculator.com/calculators/mathematics/statistics/conditional-probability-calculator

Mathematics

Statistics

Conditional Probability Calculator

Find conditional probability P(A | B) from the joint probability and P(B), solve for any value, test independence, and run Bayes' theorem with a contingency table.

Conditional Probability Calculator

%
%
%

Show all event relationships

Enter P(A) to unlock P(B|A), the union, an independence check, and the visuals.

Switch to Bayes' theorem

Find P(A|B) from a prior, a true-positive rate, and a false-positive rate.

Enter any two of P(A and B), P(B), and P(A | B). The calculator solves for the third.

Please input values into the fields

Was this calculator helpful?

It takes one click and shapes what we fix next.

Add as preferred on Google

Conditional probability is the likelihood of an event A occurring given that another event B has already occurred. This calculator computes values based on definitions found in textbooks and also supports bidirectional calculations. If you enter any two of three values (the joint probability P(A and B), the probability P(B) and the conditional probability P(A given B)),

Conditional Probability Introduction
Conditional Probability Introduction

then this tool will calculate the remaining value. By enabling additional options, you can also view the inverse conditional probability, union, test for independence and full calculation of Bayes' theorem.

What is conditional probability?

Most events in the real world are connected to each other. If it's cloudy, there is a higher chance of rain, and if a patient actually has a disease, then they have a higher chance of testing positive for that disease. Conditional probability is a tool used to deal with these situations. It poses a clear question: "What is the probability of event A happening given that event B already happened?"

What is conditional probability?
What is conditional probability?

The important thing is that knowing that B has occurred narrows the area under consideration. Instead of considering all possible outcomes, only those within B are considered. The probability that A occurs in this narrowed area is the proportion of A that also belongs to B divided by B.

How to use this calculator:

First enter the three main elements: the joint probability P(A and B), and the probability of the known event P(B). Then check the conditional probability P(A given B) in the results area. One of the three values can be left blank, as the calculator will automatically fill it out for you. So you can also work backwards from the joint probability or P(B), if the conditional probability is already known.

Two toggles allow for more detailed information to be shown. If "Show all event relationships" is checked, an input for P(A) will be requested and the inverse conditional probability P(B given A), union P(A or B), test of independence, and contingency table will be shown. If the direct value of P(B) is not known but the base rate, sensitivity (true positive rate), and false positive rate are known, switch to Bayes' theorem.

Formula for conditional probability:

The definition of conditional probability is the ratio of the joint probability of A and B to the probability of the given event.

P(A∣B)=P(A∩B)P(B),P(B)>0P(A \mid B) = \frac{P(A \cap B)}{P(B)}, \quad P(B) > 0
Conditional Probability Formula
Conditional Probability Formula

P(A and B) represents the probability that both events occur at the same time. P(B) is the probability of the conditioning event. By rearranging this relationship we get the product law. This law is useful when the conditional probability is known and the joint probability is to be found.

P(A∩B)=P(A∣B) P(B)P(A \cap B) = P(A \mid B)\,P(B)

The table below shows an example value for each input field.

Conditional Probability Example
Conditional Probability Example

Symbol

Meaning

Example

P(A and B)

Joint probability that both happen

22%

P(B)

Probability of the given event

39%

P(A | B)

Conditional probability of A given B

56%

P(A)

Marginal probability of A on its own

40%

P(B | A)

Reverse conditional, B given A

result

The result is:

Conditional Probability Calculations
Conditional Probability Calculations

So what does this mean?

Conditional Probability Explainer
Conditional Probability Explainer

Also if you notice, P(A | B) is not the same as P(B | A)

Conditional Probability Explainer
Conditional Probability Explainer

Concrete example

A bag contains 10 marbles: 7 are black and 3 are blue. If two marbles are drawn without replacement, what is the probability that the second marble is black, given that the first marble drawn was blue? After one blue marble is drawn, there are 9 marbles remaining in the bag, 7 of which are black, so the conditional probability is 7/9.

P(black second∣blue first)=79≈0.78P(\text{black second} \mid \text{blue first}) = \frac{7}{9} \approx 0.78

If we combine this with the probability of drawing a blue marble first (3/10), we get the joint probability of drawing blue and then black. This is a practical example of using the multiplication rule.

P(blue, then black)=310×79=2190≈0.233P(\text{blue, then black}) = \frac{3}{10} \times \frac{7}{9} = \frac{21}{90} \approx 0.233

Because the marbles are drawn without replacement, these two events are dependent. If the marbles were replaced, then the contents of the bag would be the same between draws and knowing the color of the first marble would not give any information about the color of the second marble.

Conditional probability, joint probability, marginal probability.

These three terms describe different questions about the same two events. The joint probability P(A and B) is the probability that both events occur simultaneously. The marginal probability P(A) gives the probability of event A occurring regardless of whether event B occurs or not. The conditional probability P(A given B) is the probability that event A occurs, given that event B has already occurred. This calculation table displays all these values in the same matrix. The joint probabilities are located in the inner cells, while the marginal sums are listed along the edges.

Bayes' theorem and the base rate fallacy.

Sometimes known conditional probabilities are presented in the wrong order. Medical tests give P(positive given disease), when patients actually want to know P(disease given positive test). Bayes' theorem allows you to switch around these conditions.

P(A∣B)=P(B∣A) P(A)P(B)P(A \mid B) = \frac{P(B \mid A)\,P(A)}{P(B)}

If the direct value of P(B) is not known, then the law of total probability can be used to compute it from the sensitivity and false positive rate.

P(B)=P(B∣A) P(A)+P(B∣¬A) P(¬A)P(B) = P(B \mid A)\,P(A) + P(B \mid \lnot A)\,P(\lnot A)

The following result is often considered surprising: if the number of people with a particular disease is 1 in 100, then the prevalence (predictive probability) is 1%. A certain test will find 90% of actual cases and has a false positive rate of 9%. Even with these values, the actual probability that someone who tests positive actually has the disease is only about 9%. The test itself is very accurate, but most of the positives are from a large number of healthy people. So low prevalence strongly affects the result. This is called "the base-rate fallacy", and can be reproduced in real time by reversing the Bayes' theorem statement.

Independent and dependent events

If knowledge of one event does not provide information about another event, the two events are independent. In this case, conditional probability reverts to regular probability so that P(A given B) is equal to P(A), and joint probability is expressed as the product of P(A) and P(B). If conditional probability does not match marginal probability, then the two events are dependent. If P(A given B) is greater than P(A), then B increases the likelihood of A occurring. If P(A given B) is less than P(A), then B decreases the likelihood of A occurring. This calculator performs this comparison by only entering P(A).

Application examples for conditional probabilities.

This concept is relevant for all kinds of everyday decisions. Doctors use it to interpret test results, spam filters assess emails based on which words increase the likelihood that they will be classified as spam, and weather forecasts update the probability of rain each time new observational data comes in. Risk models, recommendation systems, and quality control also rely on this same method. It's about refining general probabilities using available evidence.

Tips and common mistakes:

Divide the probability of a known event by the probability of the other event, not vice versa. The denominator of P(A given B) is P(B). A common mistake is to replace this with P(A). Also be careful about consistency in numbers. The combined probability can never be larger than either individual probability, so always make sure that P(A and B) is less than or equal to both P(A) and P(B). Also remember that an impossible event cannot be used as a condition. This is why P(B) must be greater than zero.

Frequently asked questions

What is the formula for conditional probability?

Conditional probability is defined as the combined likelihood of two events occurring at the same time, divided by the probability of the known event. It is calculated using: P(A given B) = P(A and B)/P(B), where P(B) must be greater than zero.

What is the difference between P(A given B) and P(B given A)?

These are different conditional probabilities. P(A given B) divides the joint probability by P(B), while P(B given A) divides the same joint probability by P(A). The two will only be equal if P(A) and P(B) are the same.

What is the relationship between Bayes' theorem and conditional probability?

Bayes' theorem transforms the definition of conditional probability by reversing the conditioning. It states that P(A given B) = (P(B given A) * P(A)) / P(B). This allows one to convert a known conditional probability into an inverse conditional probability. An example is how test results affect the likelihood of having a disease.

Why can't we set P(B) to zero?

In the calculation of conditional probabilities, we divide by P(B). If P(B) were zero, then event B would never occur, and the condition "given that B occurred" is meaningless, so this expression would be undefined.

Can I enter probabilities as a percentage?

Yes. As this calculator uses percentages for each entry, entering "25" represents a probability of 0.25. The result will also be shown as a percentage.

Related calculators

Disclaimer: This calculator is provided for general informational and educational purposes only. Our calculators are under active development, and results may be inaccurate, incomplete, or unsuitable for your situation. Always verify the figures independently and seek advice from a qualified professional before relying on them. We make no warranties and accept no liability for any loss or decision arising from use of this tool.

References

  1. Wikipedia: Conditional probability

    Definition, the multiplication rule, and independence.

  2. Investopedia: Bayes' Theorem

    Bayes' theorem, priors and posteriors, with worked examples.