Bayes' Theorem

Bayes’ theorem describes the probability of occurrence of an event related to any condition. It is also considered for the case of conditional probability. Bayes theorem is also known as the formula for the probability of “causes”. For example: if we have to calculate the probability of taking a blue ball from the second bag out of three different bags of balls, where each bag contains three different colour balls viz. red, blue, black. In this case, the probability of occurrence of an event is calculated depending on other conditions is known as conditional probability. In this article, let us discuss the statement and proof for Bayes theorem, its derivation, formula, and many solved examples.

Table of Contents:

Bayes Theorem

Bayes Theorem Statement

Let E1, E2,…, En be a set of events associated with a sample space S, where all the events E1, E2,…, En have nonzero probability of occurrence and they form a partition of S. Let A be any event associated with S, then according to Bayes theorem,

\(\begin{array}{l}P(E_i│A)~=~\frac{P(E_i)P(A│E_i)}{\sum\limits_{k=1}^{n}P(E_k)P(A| E_k)}\end{array} \)

for any k = 1, 2, 3, …., n

Bayes Theorem Proof

According to the conditional probability formula,

\(\begin{array}{l}P(E_i│A)~=~\frac{P(E_i ∩ A)}{P(A)}…(1)\end{array} \)

Using the multiplication rule of probability,

\(\begin{array}{l}P(E_i ∩ A)~= ~P(E_i)P(A │E_i)…(2)\end{array} \)

Using total probability theorem,

\(\begin{array}{l}P(A)~=~\sum\limits_{k=1}^{n}~P(E_k)P(A| E_k)…(3)\end{array} \)

Putting the values from equations (2) and (3) in equation 1, we get

\(\begin{array}{l}P(E_i│A)~=~\frac{P(E_i)P(A│E_i)}{\sum\limits_{k=1}^n~P(E_k)P(A| E_k)}\end{array} \)


The following terminologies are also used when the Bayes theorem is applied:

Hypotheses: The events E1, E2,… En is called the hypotheses

Priori Probability: The probability P(Ei) is considered as the priori probability of hypothesis Ei

Posteriori Probability: The probability P(Ei|A) is considered as the posteriori probability of hypothesis Ei
Bayes’ theorem is also called the formula for the probability of “causes”. Since the Ei‘s are a partition of the sample space S, one and only one of the events Ei occurs (i.e. one of the events Ei must occur and the only one can occur). Hence, the above formula gives us the probability of a particular Ei (i.e. a “Cause”), given that the event A has occurred.

Bayes Theorem Formula

If A and B are two events, then the formula for the Bayes theorem is given by:

\(\begin{array}{l}P(A|B)= \frac{P(B|A)P(A)}{P(B)}\:\:where\:\:P(B)\neq 0\end{array} \)

Where P(A|B) is the probability of condition when event A is occurring while event B has already occurred.
Also, get the Bayes Theorem Calculator here.

Bayes Theorem Derivation

Bayes Theorem can be derived for events and random variables separately using the definition of conditional probability and density.

From the definition of conditional probability, Bayes theorem can be derived for events as given below:

P(A|B) = P(A ⋂ B)/ P(B), where P(B) ≠ 0

P(B|A) = P(B ⋂ A)/ P(A), where P(A) ≠ 0

Here, the joint probability P(A ⋂ B) of both events A and B being true such that,

P(B ⋂ A) = P(A ⋂ B)

P(A ⋂ B) = P(A | B) P(B) = P(B | A) P(A)

P(A|B) = [P(B|A) P(A)]/ P(B), where P(B) ≠ 0

Similarly, from the definition of conditional density, Bayes theorem can be derived for two continuous random variables namely X and Y as given below:

\(\begin{array}{l}f_{X|Y=y}(x)=\frac{f_{X,Y(x,y)}}{f_Y(y)}\\f_{Y|X=x}(y)=\frac{f_{X,Y(x,y)}}{f_X(x)}\end{array} \)


\(\begin{array}{l}f_{X|Y=y}(x)=\frac{f_{Y|X=x}(y)f_X(x)}{f_Y(y)}\end{array} \)

Examples and Solutions

Some illustrations will improve the understanding of the concept.

Example 1:

A bag I contains 4 white and 6 black balls while another Bag II contains 4 white and 3 black balls. One ball is drawn at random from one of the bags, and it is found to be black. Find the probability that it was drawn from Bag I.


Let E1 be the event of choosing bag I, E2 the event of choosing bag II, and A be the event of drawing a black ball.


\(\begin{array}{l}P(E_1)~ = ~P(E_2)~ =~\frac{1}{2}\end{array} \)

Also, P(A|E1) = P(drawing a black ball from Bag I) = 6/10 = 3/5

P(A|E2) = P(drawing a black ball from Bag II) = 3/7

By using Bayes’ theorem, the probability of drawing a black ball from bag I out of two bags,

\(\begin{array}{l}P(E_1 |A)~ =~\frac{P(E_1)P(A|E_1)}{P(E_1 )P(A│E_1 )+ P(E_2)P(A|E_2)}\end{array} \)

\(\begin{array}{l}=\large\frac{\frac{1}{2}~\times~\frac{3}{5}}{\frac{1}{2}~\times~\frac{3}{5}~+~\frac{1}{2}~ ×~\frac{3}{7}}\end{array} \)

\(\begin{array}{l}=\frac{7}{12}\end{array} \)

Example 2:

A man is known to speak the truth 2 out of 3 times. He throws a die and reports that the number obtained is a four. Find the probability that the number obtained is actually a four.


Let A be the event that the man reports that number four is obtained.

Let E1 be the event that four is obtained and E2 be its complementary event.

Then, P(E1) = Probability that four occurs = 1/6.

P(E2) = Probability that four does not occur = 1- P(E1) = 1 – (1/6) = 5/6.

Also, P(A|E1)= Probability that man reports four and it is actually a four = 2/3

P(A|E2) = Probability that man reports four and it is not a four = 1/3.

By using Bayes’ theorem, probability that number obtained is actually a four, P(E1|A)

\(\begin{array}{l}= \large \frac{P(E_1)P(A|E_1)}{P(E_1 )P(A│E_1 )~+~ P(E_2)P(A|E_2)}~
=~\frac{\frac{1}{6} ~ ×~ \frac{2}{3}}{\frac{1}{6} ~×~ \frac{2}{3}~ +~ \frac{5}{6}~ ×~\frac{1}{3}}\end{array} \)

\(\begin{array}{l}=\frac{2}{7}\end{array} \)

Bayes Theorem Applications

One of the many applications of Bayes’ theorem is Bayesian inference, a particular approach to statistical inference. Bayesian inference has found application in various activities, including medicine, science, philosophy, engineering, sports, law, etc. For example, we can use Bayes’ theorem to define the accuracy of medical test results by considering how likely any given person is to have a disease and the test’s overall accuracy. Bayes’ theorem relies on consolidating prior probability distributions to generate posterior probabilities. In Bayesian statistical inference, prior probability is the probability of an event before new data is collected.

Practice Problems

Solve the following problems using Bayes Theorem.

  1. A bag contains 5 red and 5 black balls. A ball is drawn at random, its colour is noted, and again the ball is returned to the bag. Also, 2 additional balls of the colour drawn are put in the bag. After that, the ball is drawn at random from the bag. What is the probability that the second ball drawn from the bag is red?
  2. Of the students in the college, 60% of the students reside in the hostel and 40% of the students are day scholars. Previous year results report that 30% of all students who stay in the hostel scored A Grade and 20% of day scholars scored A grade. At the end of the year, one student is chosen at random and found that he/she has an A grade. What is the probability that the student is a hosteler? 
  3. From the pack of 52 cards, one card is lost. From the remaining cards of a pack, two cards are drawn and both are found to be diamond cards. What is the probability that the lost card is a diamond?

Frequently Asked Questions on Bayes Theorem


What is meant by Bayes theorem in probability?

In Probability, Bayes theorem is a mathematical formula, which is used to determine the conditional probability of the given event. Conditional probability is defined as the likelihood that an event will occur, based on the occurrence of a previous outcome.


How is Bayes theorem different from conditional probability?

As we know, Bayes theorem defines the probability of an event based on the prior knowledge of the conditions related to the event. In case, if we know the conditional probability, we can easily find the reverse probabilities using the Bayes theorem.


When can we use Bayes theorem?

Bayes theorem is used to find the reverse probabilities if we know the conditional probability of an event.


What is the formula for Bayes theorem?

The formula for Bayes theorem is:
P(A|B)= [P(B|A). P(A)]/P(B)
Where P(A) and P(B) are the probabilities of events A and B.
P(A|B) is the probability of event A given B
P(B|A) is the probability of event B given A.


Where can we use Bayes theorem?

Bayes rule can be used in the condition while answering the probabilistic queries conditioned on the piece of evidence.

Students, are you struggling to find a solution to a specific question from Bayes theorem? We will make it easy for you. For a detailed discussion on the concept of Bayes’ theorem, download BYJU’S – The Learning App.

Test your knowledge on Bayes' Theorem


Leave a Comment

Your Mobile number and Email id will not be published.



  1. Superb explanation. Thanks to bujy’s🙂

  2. Well explained theory.

  3. thank you for explaining really good

  4. well explained