conditional probability calculator

Conditional Probability Calculator

Choose a method, enter known values, and calculate P(A|B) instantly.

P(A|B) = P(A∩B) / P(B), with P(B) > 0
P(A|B) = Count(A and B) / Count(B), with Count(B) > 0
P(A|B) = [P(B|A) × P(A)] / P(B), with P(B) > 0
Tip: Enter probabilities as decimals (0 to 1). For percentages, divide by 100 first.

What Is Conditional Probability?

Conditional probability measures the chance that an event A occurs, given that another event B has already occurred. This is written as P(A|B) and read “the probability of A given B.” In practical terms, conditional probability helps you update uncertainty when new information becomes available.

For example, the probability that a random person has a disease might be low. But if you know their test result is positive, the relevant probability changes. That updated probability is a conditional probability.

Core Formula

Standard definition

P(A|B) = P(A ∩ B) / P(B), provided that P(B) > 0.

  • P(A ∩ B): probability both A and B happen
  • P(B): probability B happens
  • P(A|B): probability A happens among cases where B is true

Frequency version

If you have counts instead of probabilities, you can use: P(A|B) = Count(A and B) / Count(B). This is exactly the same idea, just expressed with observed data.

How to Use This Conditional Probability Calculator

  • Pick a method: direct probabilities, counts, or Bayes' theorem.
  • Enter your known values in decimal form for probabilities.
  • Click Calculate to compute P(A|B).
  • Use Reset to clear all fields and start over.

The calculator also checks for inconsistent values (for example, if P(A∩B) is larger than P(B)), helping prevent impossible results.

Worked Examples

Example 1: Card probability

Let A = “card is a king,” and B = “card is a face card.” There are 4 kings and 12 face cards in a 52-card deck. So, P(A ∩ B) = 4/52 and P(B) = 12/52. Then: P(A|B) = (4/52)/(12/52) = 4/12 = 1/3 ≈ 0.3333.

Example 2: Medical test interpretation

Let A = “patient has condition,” B = “test is positive.” Suppose:

  • P(B|A) = 0.90 (sensitivity)
  • P(A) = 0.05 (prevalence)
  • P(B) = 0.08 (overall positive rate)

With Bayes: P(A|B) = (0.90 × 0.05) / 0.08 = 0.5625. So a positive test corresponds to a 56.25% chance of truly having the condition.

Example 3: Quality control

In a factory, B = “item selected from Line 2” and A = “item is defective.” If 200 items are from Line 2 and 18 of those are defective, then: P(A|B) = 18/200 = 0.09. The defect rate for Line 2 is 9%.

Common Mistakes to Avoid

  • Confusing P(A|B) with P(B|A) (they are usually different).
  • Entering percentages directly (use 25% as 0.25).
  • Using zero for the denominator event: if P(B)=0, conditional probability is undefined.
  • Using inconsistent inputs, such as P(A∩B) > P(B).

Why Conditional Probability Matters

Conditional probability is foundational in statistics, machine learning, risk management, finance, medicine, and decision science. Anytime you update beliefs based on new evidence, you are effectively using conditional probability.

This calculator provides a fast way to compute reliable results for homework, analytics workflows, and real-world decision support.

Quick FAQ

Can the result ever be greater than 1?

No. A valid probability must always be between 0 and 1 inclusive.

Can I use this as a Bayes theorem calculator?

Yes. Choose the Bayes mode and enter P(B|A), P(A), and P(B).

What if I only have a contingency table?

Use the counts mode with table frequencies. It directly computes the same conditional probability.

🔗 Related Calculators