Free preview

88 lessons

Essential Probability & Statistics for ML

Free preview

Essential Probability & Statistics for ML · 88 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 odds form of Bayes' rule

The odds form of Bayes' rule

Explanation

We've seen that the likelihood ratio compares how probable the evidence EE is under HH and under HcH^c. What we usually want is the conditional probability the other way round: P(H∣E)P(H \mid E), the posterior probability of HH once EE is observed.

Bayes' rule gives P(H∣E)P(H \mid E), but it needs the denominator P(E)P(E), which usually takes the law of total probability to find. Written in terms of odds, Bayes' rule becomes simpler: P(E)P(E) cancels, and the evidence enters through a single multiplication by the likelihood ratio.

To write Bayes' rule in terms of odds, we need the odds of HH before and after EE is observed.

Prior and posterior odds

Definition

For a hypothesis HH and evidence EE, the prior odds of HH are its odds before EE is observed:

odds(H)=P(H)P(Hc)\text{odds}(H) = \dfrac{P(H)}{P(H^c)}

The posterior odds are its odds after EE is observed:

odds(H∣E)=P(H∣E)P(Hc∣E)\text{odds}(H \mid E) = \dfrac{P(H \mid E)}{P(H^c \mid E)}

Bayes' rule gives both posterior probabilities with the same denominator, P(E)P(E):

P(H∣E)=P(E∣H) P(H)P(E)P(Hc∣E)=P(E∣Hc) P(Hc)P(E)\begin{align*} P(H \mid E) &= \dfrac{P(E \mid H)\,P(H)}{P(E)} \\[6pt] P(H^c \mid E) &= \dfrac{P(E \mid H^c)\,P(H^c)}{P(E)} \end{align*}

Dividing the first by the second cancels P(E)P(E):

P(H∣E)P(Hc∣E)⏟posterior odds=P(H)P(Hc)⏟prior odds×P(E∣H)P(E∣Hc)⏟likelihood ratio\underbrace{\dfrac{P(H \mid E)}{P(H^c \mid E)}}_{\text{posterior odds}} = \underbrace{\dfrac{P(H)}{P(H^c)}}_{\text{prior odds}} \times \underbrace{\dfrac{P(E \mid H)}{P(E \mid H^c)}}_{\text{likelihood ratio}}
The odds form of Bayes' rule

Theorem

For a hypothesis HH with 0<P(H)<10 < P(H) < 1 and evidence EE with P(E∣Hc)>0P(E \mid H^c) > 0,

odds(H∣E)=odds(H)×P(E∣H)P(E∣Hc)\text{odds}(H \mid E) = \text{odds}(H) \times \dfrac{P(E \mid H)}{P(E \mid H^c)}

In words, the posterior odds are the prior odds times the likelihood ratio. Before EE is observed, the odds of HH are the prior odds. Observing EE updates them by multiplying by the likelihood ratio: evidence that favours HH has a ratio above 11 and raises the odds, and evidence against HH has a ratio below 11 and lowers them.

Example

A machine part is faulty with probability 0.20.2. A quality check flags 0.90.9 of faulty parts and 0.150.15 of parts that work. Find the odds that a flagged part is faulty.

Solution

We name the hypothesis and the evidence:

  • HH: the part is faulty.
  • EE: the check flags the part.

The prior is P(H)=0.2P(H) = 0.2, so P(Hc)=0.8P(H^c) = 0.8 and the prior odds are

odds(H)=0.20.8=14\text{odds}(H) = \dfrac{0.2}{0.8} = \dfrac{1}{4}

Each figure is a likelihood, P(E∣H)=0.9P(E \mid H) = 0.9 and P(E∣Hc)=0.15P(E \mid H^c) = 0.15, so the likelihood ratio is

P(E∣H)P(E∣Hc)=0.90.15=6\dfrac{P(E \mid H)}{P(E \mid H^c)} = \dfrac{0.9}{0.15} = 6

Multiplying the prior odds by it gives the posterior odds:

odds(H∣E)=14×6=32\begin{align*} \text{odds}(H \mid E) &= \dfrac{1}{4} \times 6 \\[6pt] &= \dfrac{3}{2} \end{align*}

The odds that a flagged part is faulty are 33 to 22.

Practice questions

4 questions

The odds that a delivery van breaks down this month are 11 to 2020. Its warning light comes on 1010 times as often in months when the van breaks down as in months when it does not.

Given that the warning light comes on, what are the odds that the van breaks down this month?

Select the correct answer:

+ 3 more questions

From posterior odds to a posterior probability

Explanation

The odds form of Bayes' rule gives the posterior odds of HH, but often what we want is the posterior probability P(H∣E)P(H \mid E).

Recall that when the odds of an event are a single number oo, its probability is o1+o\dfrac{o}{1 + o}. So once we have the posterior odds, o=odds(H∣E)o = \text{odds}(H \mid E), the posterior probability is

P(H∣E)=o1+oP(H \mid E) = \dfrac{o}{1 + o}

Example

Of a bank's transactions, 0.010.01 are fraudulent. An alert is raised 3333 times as often on fraudulent transactions as on genuine ones. Find the probability that an alerted transaction is fraudulent.

Solution

We name the hypothesis and the evidence:

  • HH: the transaction is fraudulent.
  • EE: an alert is raised.

The prior is P(H)=0.01P(H) = 0.01, so P(Hc)=0.99P(H^c) = 0.99 and the prior odds are

odds(H)=0.010.99=199\text{odds}(H) = \dfrac{0.01}{0.99} = \dfrac{1}{99}

An alert is raised 3333 times as often when HH holds as when it does not, so the likelihood ratio is 3333. Multiplying the prior odds by it gives the posterior odds:

odds(H∣E)=199×33=13\begin{align*} \text{odds}(H \mid E) &= \dfrac{1}{99} \times 33 \\[6pt] &= \dfrac{1}{3} \end{align*}

We convert the posterior odds o=13o = \dfrac{1}{3} to a probability with o1+o\dfrac{o}{1 + o}:

P(H∣E)=1/31+1/3=1/34/3=0.25\begin{align*} P(H \mid E) &= \dfrac{1/3}{1 + 1/3} \\[6pt] &= \dfrac{1/3}{4/3} \\[6pt] &= 0.25 \end{align*}

An alerted transaction is fraudulent with probability 0.250.25.

Practice questions

4 questions

Given that a patient tests positive, the odds that they have the condition are 33 to 22.

What is the probability that a patient who tests positive has the condition?

Select the correct answer:

+ 3 more questions