
Basic knowledge of probability is useful for everyone but it becomes even more useful if you work with real life problems. Then probability helps you to account and understand the uncertainty that we see in the real world.
Probability gives us the tools to measure and quantify the uncertainty on the events that we model or that we try to replicate. Another good reason is that many algorithms and models use probability as their base, like ‘Probabilistic Graphical models’ and ‘Naive Bayes models’.
That is one of the reasons why you will get tested on the Interview about probability. As a quick refresher, keep the axioms of probability in mind:
Axioms
Non-Negativity:

Additivity:

Normalisation:

Bayes’ Theorem:
Another very important theorem to keep in mind is the Bayes’ Theorem:

And now as promised we can start with some Q&A…
Two out of three
Suppose you flip a fair coin 3 times. What is the Probability of getting exactly two heads?
Note: Fair coin means that every possible result has the same probability.
Every flip has the same probability (0.5) of getting heads (H) or tails (T). Since we have 2 possible events and three flips, we have 8 permutations (2³).
The possible cases are: HHH, HHT, HTH, THH, HTT, THT, TTH, TTT
P(3H) + P(2H) + P(2T) + P(3T) = 1
It’s easy to observe that: P(3H) = P(3T) = 1/8 and P(2H) = P(2T)
2P(2H) = 1 – 2P(3H) = 1–(2/8) → P(2H) = 3/8
A variation of this problem is to answer what is the probability of getting at least 2 heads, which is easy enough to calculate… (ok, it’s 0.5)
Just for your interest, you may want to read about the gambler’s fallacy.
Biased dice
The probability of our biased dice is proportional to each number on the dice and we roll this dice twice.
What is the probability of getting one even and one odd number?
The probability of any number is proportional to itself and the total must be 1:
P(1+2+3+4+5+6) = 1
P(1) = 1/21
P(2) = 2/21
…
P(6) = 6/21
From this we calculate the probabilities of odd (O) and even (E) numbers:
P(O) = (1+3+5)/21 = 3/7
P(E) = (2+4+6)/21 = 4/7
Now the only thing left is to realise that there are two scenarios where we can end up with the desired result. The 1st scenario is to get 1st the odd number and in the 2nd throw the even number. And the 2nd scenario is to get 1st the even number and in the 2nd the odd number.
P(O U E) = P(1st O & 2nd E) + P(1st E & 2nd O)
P(O U E) = 24/49
There are more ways to solve this problem and different ways to thing about it. For example by using the relations between the events. We have four permutations in which one is the 2 odd numbers and another is the 2 even numbers:
P(O U E) = 1-P(2 O) – P(2 E) = 1–(9/49)-(16/49) = 24/49
P(O U E) = 2 (3/7 4/7) = 24/49
A/B Testing
Your company is running a test that is designed to compare two different versions of the company's website.
Version A of the website is shown to 65% of users, while version B of the website is shown to the remaining 35%.
The test shows that 9% of users who are presented with version A sign up for the company's services, as compared to 5% of users who are presented with version B.
If a user signs up for the company's services, what is the probability that she/he was presented with the version A of the website?
Now it is time to apply that conditional probability that we have seen at the beginning. The data we will work with is:

The probability of a user signing up and visiting a specific version is calculated by multiplying the chance of the website being presented to the user by its conversion ratio.


That wasn’t that hard, right?
Second Girl Probability
Marie has 2 kids and we know that one of them is a girl.
What is the probability the other kid is also a girl?
Assume there is equal probability of getting a girl and a boy.
This is again a problem that we can tackle in different ways….
The possible cases for boy (b) and girl (g) are: bb, bg, gb, and gg
The first way of thinking about this problem is to realise that we already know that one of the kids is a girl, so in reality we have only 3 cases: bg, gb and gg
And within these 3 cases only one is gg, so the answer is 1/3
The second way of solving the problem involves using Bayes’ Theorem:

Did you find it interesting? Truth is, this is an old problem that you may have heard already as the Boy or Girl paradox and I invite you to read more about it in the link…
Russian Roulette

This is another classic of probability:
You are playing a version of the Russian roulette where
the revolver has two consecutive bullets.
Your opponent puts the two consecutive bullets in the chambers of the revolver. The revolver has six chambers.
Then he puts the revolver in his head, pulls the trigger and survives.
Now is your turn and you're given two choices:
- Put the gun straight to your head and pull the trigger.
- Spin the cylinder of the revolver before putting the gun in your head and pulling the trigger.
Which one do you choose and why?
The assumptions that are not mentioned in the previous points are:
- Your objective is to survive the game.
- Spinning the revolver gives us a completely random result not influenced by the weight of the bullets or anything else.
- The revolver never gets jammed and never misses.
To answer this question let’s take any of the possible positions:
x | B | B | x | x | x
The main point is to be aware of the fact that when the opponent pulls the trigger and it didn’t fire, there are 4 positions or possibilities in which the revolver may have been, that we have marked with ‘x‘.
For three of these positions we will be safe in the next pull of the trigger and only in one the revolver will fire in the next trigger. Let’s call P(S) the probability of survival, then the probability of survival without spinning again the revolver is:

If I spin the revolver the probability of ending on any chamber is the same (1 across 6) and there are 2 possibilities (bullets) out of 6 of finding a bullet which is 4 possibilities out of 6 of finding an empty chamber:

So I wouldn’t spin the cylinder if I were you…
Russian Roulette Variation
And now a simple variation of the previous problem:
Now between the 2 bullets we have at least 2 empty chambers. Everything else is the same as before.
Again you're given two choices:
- Put the gun straight to your head and pull the trigger
- Spin the cylinder of the revolver before putting the gun in your head and pulling the trigger
Which one do you choose and why?
There is a trick in the question and it is that there can not be more than two empty chambers of separations as we would leave 3 empty on one side of the bullet and only 1 on the other. So we end up with this scenario:
B | x| x | B | x | x
Which we can simplify to: B | x| x
We have only two possible positions for when our opponent didn’t find a bullet and from those two positions only one is safe for us in the next round…

And there are no variations vs. the previous problem is we spin the revolver, as all events have equal probability:

So now is marginally better if we spin it.
Though this won’t give you a huge edge if you plan on playing… 😅
Thanks for reading
I hope that you enjoyed this article and maybe I inspired you some extra curiosity to search for more… many of these problems can be found in wikipedia and similar sources so I invite you to dig a little more into this fascinating world.
Please leave your thoughts and ideas and let me know what other topics may be of your interest.