Free preview

74 lessons

Essential Probability & Statistics for ML

Free preview

Essential Probability & Statistics for ML · 74 lessons

Master the fundamentals

No surprise gaps

Actually remember it

Skip what you know

One subscription. All learning paths included.

Our content is best on a larger screen

The conditional probability formula

The formula from probabilities

Explanation

We've seen that when outcomes are equally likely, we find P(A∣B)P(A \mid B) by restricting to the known event BB and counting. Counting relies on every outcome being equally likely. When outcomes have different probabilities, we restrict to BB in the same way, but measure each region by its probability rather than by its number of outcomes.

The diagram below conditions on BB in steps, with the probability of each region written in.

Ω
A
B
0.2
0.3
0.4
A∩B
0.1

Step 1: The four regions

Each region of Ω is labelled with its probability: A only 0.2, both 0.1, B only 0.3, and neither 0.4. Together they total 1.

Step 2: Restrict to B

We learn that B happens, so every outcome outside B is ruled out. Only the two regions of B remain, and their probabilities total

P(B)=0.1+0.3=0.4

Step 3: B becomes the whole

Once we know that B happens, B is everything that can happen: its 0.4 now plays the part that 1 played before. So we rescale, measuring each region as a share of B: both is 0.1 out of 0.4, a quarter of B, and B only is 0.3 out of 0.4, three quarters.

0.10.4=0.250.30.4=0.75

The shares total 1: a conditional probability is still a probability.

Step 4: Read off A

Now A can happen only if B happens too, so all that is left of A is the overlap A∩B. P(A∣B) is the overlap’s share of B:

P(A∣B)=0.10.4=0.25

This is the counting rule from before, the outcomes in both divided by the outcomes in B, with probabilities in place of counts.

If A and B had no overlap, nothing of A would be left once we restrict to B, and P(A∣B) would be 0.

Restricting and rescaling work the same way for any events, so we take the result as the definition of conditional probability.

The conditional probability formula

Definition

For events AA and BB with P(B)>0P(B) > 0, the conditional probability of AA given BB is

P(A∣B)=P(A∩B)P(B)P(A \mid B) = \dfrac{P(A \cap B)}{P(B)}

We need P(B)>0P(B) > 0 because the formula divides by P(B)P(B): an event that cannot happen can never be learned, so there is nothing to restrict to.

Example

A die is loaded: faces 11 to 66 have probabilities 0.10.1, 0.30.3, 0.20.2, 0.10.1, 0.10.1 and 0.20.2. Given that the roll is at most 33, find the probability that it is odd.

Solution

We name the two events. The roll being at most 33 is what we know, so it is the known event:

  • B={1,2,3}B = \{1, 2, 3\}, the roll is at most 33.
  • A={1,3,5}A = \{1, 3, 5\}, the roll is odd.

We want P(A∣B)P(A \mid B). The table marks the faces in BB and those also in AA:

Face112233445566
Probability0.10.10.30.30.20.20.10.10.10.10.20.2
In BBYesYesYes
In A∩BA \cap BYesYes

Adding the marked probabilities:

P(B)=0.1+0.3+0.2=0.6P(A∩B)=0.1+0.2=0.3\begin{align*} P(B) &= 0.1 + 0.3 + 0.2 = 0.6 \\[6pt] P(A \cap B) &= 0.1 + 0.2 = 0.3 \end{align*}

We rescale by dividing by P(B)P(B):

P(A∣B)=P(A∩B)P(B)=0.30.6=12\begin{align*} P(A \mid B) &= \dfrac{P(A \cap B)}{P(B)} \\[6pt] &= \dfrac{0.3}{0.6} \\[6pt] &= \dfrac{1}{2} \end{align*}

Given that the roll is at most 33, it is odd with probability 12\dfrac{1}{2}.

Counting faces would give 23\dfrac{2}{3}, since two of the three faces in BB are odd. That treats faces 11, 22 and 33 as equally likely, but face 22 alone has probability 0.30.3, which is half of P(B)P(B).

Practice questions

4 questions

On a weekday morning, it rains with probability 0.30.3 and a commuter's bus is late with probability 0.250.25. The probability that it rains and the bus is late is 0.10.1.

Given that it rains, what is the probability that the bus is late?

Select the correct answer:

+ 3 more questions

Probability rules given an event

Explanation

A probability function is any function that satisfies the two axioms of probability. If conditional probabilities given BB satisfy them as well, they are probabilities, and every rule that follows from the axioms holds for them too. We check each axiom in turn, using the conditional probability formula.

Axiom 1 says the impossible event has probability 00 and the certain event has probability 11. Given BB, the impossible event still has no outcomes, so ∅∩B=∅\emptyset \cap B = \emptyset and

P(∅∣B)=P(∅∩B)P(B)=P(∅)P(B)=0P(\emptyset \mid B) = \dfrac{P(\emptyset \cap B)}{P(B)} = \dfrac{P(\emptyset)}{P(B)} = 0

Once we know that BB happens, every outcome left is in BB, so Ω∩B=B\Omega \cap B = B and

P(Ω∣B)=P(Ω∩B)P(B)=P(B)P(B)=1P(\Omega \mid B) = \dfrac{P(\Omega \cap B)}{P(B)} = \dfrac{P(B)}{P(B)} = 1

So the probabilities given BB total 11, and axiom 1 holds.

Axiom 2, additivity, holds given BB as well. If two events A1A_1 and A2A_2 have no outcome in common, neither do their parts inside BB, and rescaling divides every probability by the same number, P(B)P(B), so a sum of probabilities stays a sum:

P(A1∪A2∣B)=P(A1∣B)+P(A2∣B)P(A_1 \cup A_2 \mid B) = P(A_1 \mid B) + P(A_2 \mid B)

This is additivity with ∣B\mid B written after every probability.

Why additivity holds given BB

Details

So conditional probabilities given BB satisfy both axioms: they are probabilities. Every rule that follows from the axioms, such as the complement rule and the general addition rule, therefore holds given BB.

Probability rules given an event

Theorem

For an event BB with P(B)>0P(B) > 0, every rule of probability holds given BB. For example,

P(Ac∣B)=1−P(A∣B)P(A∪C∣B)=P(A∣B)+P(C∣B)−P(A∩C∣B)\begin{align*} P(A^c \mid B) &= 1 - P(A \mid B) \\[6pt] P(A \cup C \mid B) &= P(A \mid B) + P(C \mid B) - P(A \cap C \mid B) \end{align*}

Key Point

To use a rule of probability given BB, we write the rule as usual and add ∣B\mid B after every probability in it. Nothing else changes: BB stays the known event in every term.

Example

In a sports club, 40%40\% of members play tennis and 15%15\% play both tennis and squash. A member chosen at random plays tennis. Find the probability that they do not play squash.

Solution

We name the events. That the member plays tennis is what we know, so it is the known event:

  • TT: the member plays tennis, with P(T)=0.4P(T) = 0.4.
  • SS: the member plays squash, with P(S∩T)=0.15P(S \cap T) = 0.15.

We want P(Sc∣T)P(S^c \mid T). The complement rule holds given TT:

P(Sc∣T)=1−P(S∣T)P(S^c \mid T) = 1 - P(S \mid T)

So we first find P(S∣T)P(S \mid T) with the conditional probability formula:

P(S∣T)=P(S∩T)P(T)=0.150.4=0.375\begin{align*} P(S \mid T) &= \dfrac{P(S \cap T)}{P(T)} \\[6pt] &= \dfrac{0.15}{0.4} \\[6pt] &= 0.375 \end{align*}

Substituting into the complement rule:

P(Sc∣T)=1−0.375=0.625\begin{align*} P(S^c \mid T) &= 1 - 0.375 \\[6pt] &= 0.625 \end{align*}

A member who plays tennis does not play squash with probability 0.6250.625.

Practice questions

5 questions

Among patients with a cough, the probability of flu is 0.350.35. Given that a patient has a cough, what is the probability that they do not have flu?

Select the correct answer:

+ 4 more questions