Bayes' Theorem Calculator

Enter P(A), P(B given A) and P(B given not A) to reverse the conditional with Bayes' theorem.

A probability from 0 to 1, as a decimal or a fraction.

A probability from 0 to 1, as a decimal or a fraction.

A probability from 0 to 1, as a decimal or a fraction.

Try

Result

You enteredP(A)=0.3, P(B∣A)=0.9, P(B∣A′)=0.2P(A) = 0.3,\ P(B \mid A) = 0.9,\ P(B \mid A') = 0.2

P(A∣B)=0.658537\displaystyle P(A \mid B) = 0.658537

P(B)

0.41\displaystyle 0.41

P(not A | B)

0.341463\displaystyle 0.341463

Fraction

2741\displaystyle \frac{27}{41}
Show the work
  1. Law of total probability

    BB can only happen together with AA or together with the complement A′A', and these two cases do not overlap, so the chance of BB is the sum of the two. Here P(A)=0.3P(A) = 0.3, P(A′)=0.7P(A') = 0.7, P(B∣A)=0.9P(B \mid A) = 0.9 and P(B∣A′)=0.2P(B \mid A') = 0.2.

    P(B)=P(B∣A)P(A)+P(B∣A′)P(A′)=0.9×0.3+0.2×0.7=0.27+0.14=0.41\begin{aligned} P(B) &= P(B \mid A)P(A) + P(B \mid A')P(A') \\ &= 0.9 \times 0.3 + 0.2 \times 0.7 \\ &= 0.27 + 0.14 \\ &= 0.41 \end{aligned}
  2. Bayes' theorem

    Bayes' theorem turns the chance of BB given AA around: the part of BB that comes through AA, divided by the whole of BB. Here P(B)=0.41P(B) = 0.41.

    P(A∣B)=P(B∣A)P(A)P(B)=0.9×0.30.41=0.270.41=2741≈0.658537\begin{aligned} P(A \mid B) &= \frac{P(B \mid A)P(A)}{P(B)} \\ &= \frac{0.9 \times 0.3}{0.41} \\ &= \frac{0.27}{0.41} \\ &= \frac{27}{41} \approx 0.658537 \end{aligned}
  3. Complement given B

    Given BB, either AA happened or it did not, and the two chances add up to 11.

    P(A′∣B)=1−P(A∣B)=1−2741=1441≈0.341463\begin{aligned} P(A' \mid B) &= 1 - P(A \mid B) \\ &= 1 - \frac{27}{41} \\ &= \frac{14}{41} \approx 0.341463 \end{aligned}
  4. Result

    So, given that BB has happened, the probability of AA is 2741≈0.658537\frac{27}{41} \approx 0.658537.

Worked examples