Free preview
80 lessons
Essential Probability & Statistics for ML
Free preview
Essential Probability & Statistics for ML · 80 lessons
No surprise gaps
Actually remember it
Skip what you know
One subscription. All learning paths included.
Our content is best on a larger screen
Which is larger, or ?
One card is drawn from a shuffled deck. Is it more likely to be red given that it is an ace, or an ace given that it is red?
Half of the aces are red, but very few red cards are aces. The diagram below finds both conditional probabilities from the same four regions.
Each region of
Both conditional probabilities use the same overlap, the
The same holds for any events and . The conditional probability formula gives and the same numerator:
Dividing the same numerator by the smaller denominator gives the larger probability:
Theorem
For events and that can both happen, if then
and if then the two are equal.
In words, the conditional probability given the rarer event is the larger. Deciding needs only which event is rarer, not the value of .
Practice questions
4 questions
Events and can both happen, with and .
Which is true?
Select the correct answer:
+ 3 more questions
Bayes' rule
Often we know the probability of the evidence given a cause, such as how often a fire makes smoke, but want the probability of the cause given the evidence: how likely a fire is, given smoke. Bayes' rule turns one of these conditional probabilities into the other.
It is one of the most used results in probability, behind spam filters, medical diagnosis and models that update their probabilities as data arrives.
It needs nothing new, only the multiplication rule for probabilities and the conditional probability formula.
The overlap can be reached from either event, so the multiplication rule writes its probability in two ways:
Both right-hand sides equal the same probability, so they equal each other:
Dividing both sides by gives Bayes' rule, also called Bayes' theorem:
Theorem
For events and with and ,
In words, Bayes' rule finds from the reverse conditional probability, , and the probability of each event.
In a town, of days are rainy, and of rainy days start cloudy. Of all days, do not start cloudy. Given that a day starts cloudy, find the probability that it is rainy.
Solution
We name the events for a day chosen at random:
The is a share of rainy days, so . We want , the reverse conditional probability, so we use Bayes' rule:
We are given the probability that a day does not start cloudy, so the complement rule gives the denominator:
We substitute the three values:
Given that a day starts cloudy, it is rainy with probability .
Practice questions
4 questions
On of days there is a fire in a warehouse, and on of days its smoke alarm sounds. The alarm sounds on of the days with a fire.
Given that the alarm sounds on a day, what is the probability that there is a fire?
Select the correct answer:
+ 3 more questions
Prior, likelihood and posterior
Bayes' rule describes how a probability changes when we learn something. It turns the probability of an event before we learn that happened into its probability after. Each part of the rule has a name for its role in this update.
Definition
In Bayes' rule, with the event we ask about and the event we learn,
The denominator , the probability of what we learn, has no name here.
"Prior" and "posterior" mean before and after learning : the prior is where we start, and the posterior is where we end up once is known.
The likelihood is a probability of , not of : it says how probable what we learned is if holds. Bayes' rule multiplies the prior by a factor built from it:
The factor compares how probable is when holds with how probable is overall. If it is above , learning raises the probability of ; if it is below , learning lowers it.
ML Context
In machine learning, a model makes predictions using numbers called parameters, whose values are learned from data. Write for one choice of parameter values and for the observed data. Bayes' rule then reads
Many models are fitted by maximum likelihood: among all choices of , it picks the one with the largest likelihood , the one that makes the observed data most probable. The prior plays no part.
Bayesian inference uses the whole rule. It starts from a prior , saying which values are plausible before seeing the data, and finds the posterior : how plausible each value is afterwards, not only which one fits best.
Of the items a factory makes, come from a machine with a fault. Of the items from a faulty machine, are defective, and of all items, are defective. An item is found to be defective. For the probability that it came from a faulty machine, name the prior, likelihood and posterior.
Solution
We start with the event asked about. We learn that the item is defective and ask whether it came from a faulty machine, so:
The fault came before the defect, but the names follow the event we ask about, not the order in which events happen, so the fault is .
The and the are shares of all items, and the is a share of items from a faulty machine:
Then we label the roles:
The is and has no name here.
Practice questions
4 questions
In a region, of houses flood each year. Of the houses that flood, stand by the river, and of all houses, stand by the river.
We learn that a house stands by the river and ask how likely it is to flood. What is the likelihood?
Select the correct answer:
+ 3 more questions