# Statistics for Data Science: Visualising Conditional Probability

--

I have been thinking of writing an article about the visual representation of the Bayes Theorem for some time. However, when I sat down to write it, I found that breaking the article into two is better, as it was getting too long. In the first article here, I am giving a visual intuition about conditional probability, and then I will proceed to Bayes Theorem in the following article.

Before we start, let us go over a few definitions :

Sample Space

A sample space is the set of all possible outcomes of a random experiment. For example, in the throwing of a dice, the sample space will consist of the outcomes {1,2,3,4,5,6}. This article will denote the sample space by rectangle U. As the sample space contains all the possible outcomes in any experiment, P(U) = 1, always.

Event

An event in any random experiment is a subset of the sample space of that experiment. For example, in the dice roll experiment, an event A can denote that the outcome is an even number, written in the set form as {2,4,6}. In this article, the events are represented by circles inside the sample space, shown as rectangles.

For this article, we will assume that we have drawn these figures so that, area of each of these figures is directly proportional to the number of possible outcomes inside that particular subset or event. And also that the area of the rectangle representing the sample space U is 1 unit, that is,

i) Area(U) = 1

So in the dice roll example, as the number of outcomes possible in event A is half that of U,

ii) Area(A) = 1/2,

Also, by the definition of probability,

P(A) = no. of outcomes possible in event A/total no. of outcomes possible

And as the number of outcomes is directly proportional to the area as per our representation, we can write

P(A) = Area(A)/Area(U)

from 1 and 2 above,

P(A) = 1/2

Now using this formulation, let us arrive at the formula for conditional probability using geometric intuition :

Conditional Probability

The conditional probability of an event A, given that an event B has already occurred, is given by

P(A|B) = P(A∩B)/P(B)

where P(A∩B) is the probability that event A and B both occur together.

To derive the above formula geometrically, let us consider the dice roll example from above, with U and A same as before, while adding the event B, which is the event of the occurrence of numbers less than equal to 4.

So, U~ {1,2,3,4,5,6},

A ~ {2,4,6}, and

B ~ {1,2,3,4}

This can be represented visually as :

Here, as before Area(U) = 1, and

iii) P(B) = Area(B)/Area(U) = Area(B), and

iv) P(A∩B) = Area(A∩B)/Area(U) = Area(A∩B) ,

which is shown as the shaded region between the 2 circles.

If we know that event B has already occurred, circle B becomes the sample space now, since all the possible outcomes are inside B.

Here, as before Area(U) = 1, and

iii) P(B) = Area(B)/Area(U) = Area(B), and

iv) P(A∩B) = Area(A∩B)/Area(U) = Area(A∩B) ,

which is shown as the shaded region between the 2 circles.

If we know that event B has already occurred, circle B becomes the sample space now, since all the possible outcomes are inside B.

Image By Author

And now the probability of A occurring, given B has occurred, is given by

P(A|B) = Area(A∩B)/Area(B)

from iii) and iv),

P(A|B) = P(A∩B)/P(B)

which is also the definition of conditional probability.

The geometrical proof for the conditional probability formula was quite simple enough, and we will build upon this to visualise Bayes Theorem in the next article.

Your comments and suggestion are welcome. Subscribe if you would like to read more articles like this in future. Thank you.