Probability for Machine Learning
uncertainty modeling, random variables, and probabilistic foundations
Core Concepts Covered
- Conditional probability, Bayes Theorem, and independence
- Discrete and continuous random variables and distributions
- Expectation, variance, covariance, and high-dimensional Gaussian mechanics
1. Axioms of Probability and Bayes' Theorem
In machine learning, we deal with noisy, incomplete, or chaotic environments. We use probability to represent and reason about this uncertainty. Instead of asserting absolute binary facts, probability allows models to express predictions as confidence percentages (for example: 'this image is likely to be a cat').
• Conditional Probability (): The probability of event occurring, given that event has already occurred:
• Statistical Independence: Events and are independent if the occurrence of does not affect the probability of , meaning or equivalently .
• Bayes' Theorem (Bayesian Inference): The mathematical bedrock of probabilistic machine learning. It allows us to update our prior belief about an event () after observing new evidence (). It maps the relationship between prior, likelihood, evidence, and posterior:
Spam Filter Trace: Let's calculate whether an incoming email containing the word free () is actually spam (): - Prior belief: of all emails are spam: . - Likelihood: of spam emails contain the word free: . - General Evidence: of all emails contain the word free: . - Applying Bayes' Theorem: This calculation proves that observing the word free updates our belief from prior to a posterior probability that the email is spam!
Bayes Rule Reverses the Conditioning Direction
Read diagram labels
- start
- D
- ¬D
- +
- −
- P(D|+) = P(+|D)P(D) / P(+)
Bayes' Theorem with Base Rates
A condition affects of people. A test has sensitivity and a false-positive rate. What is ?
1..
2..
Even a positive test gives about posterior probability because false positives come from the much larger healthy group.
Sensitivity alone is not a posterior probability; the base rate matters.
2. Random Variables, Expectation, and Covariance
A random variable is a variable whose possible values are numerical outcomes of a random process. They are categorized into discrete (taking countable values like a dice roll) or continuous (taking any real value in an interval like temperature).
• PMF vs. PDF: Discrete variables are defined by a Probability Mass Function (PMF), while continuous variables are defined by a continuous Probability Density Function (PDF) integrated to find probabilities over ranges.
• Expectation (): The theoretical mean or average value of a random variable over infinite trials. For discrete variables, it is: ,
• Variance (): Measures how spread out the values are from their mean value: ,
Discrete Dice Trace: Let's calculate the expectation and variance of rolling a fair 4-sided die (, each with probability ): - Expectation : - Expected Squared Value : - Variance : This gives us a precise mathematical measure of the spread of the die's outcomes!
• Covariance (): Measures joint linear movement. Correlation standardizes it: . Independence implies zero covariance when moments exist, but zero covariance does not generally imply independence.
Expectation, Covariance, and Correlation
Let be or , each with probability . Find means, covariance, and correlation.
1., , and .
2..
and , so .
Independence Check
If , , and , are and independent?
1.Compute .
This equals , so the events are independent.
3. Probability Distributions & High-Dimensional Gaussians
A probability distribution is a mathematical profile mapping the likelihood of all possible values for a random variable. The most important distribution in machine learning is the Gaussian (Normal) Distribution due to the Central Limit Theorem, which states that sums of independent random variables tend to converge to a normal distribution.
The standard single-variable normal PDF with mean and variance is:
In high-dimensional spaces, the multivariate Gaussian for has mean and covariance :
where is the determinant of the covariance matrix. Geometrically, the mean vector translates the center of the distribution in space, while the covariance matrix scales and rotates the probability density ellipses. The eigenvalues of represent the variance scales along those rotated principal axes!
Covariance Controls Gaussian Orientation and Spread
Read diagram labels
- largest variance
- smaller variance
Compare Four Distribution Families
Match and calculate: Bernoulli(), Binomial(), Uniform(), and Gaussian().
1.Bernoulli mean/variance: and .
2.Binomial mean/variance: and .
3.Uniform mean/variance: and .
Gaussian mean is and variance is , so its standard deviation is .
A Two-Dimensional Gaussian Contour
For and , compare the Mahalanobis squared distances of and .
1..
2., while .
The density extends farther along the -axis because that direction has variance .
Interactive Practice Quiz
Test your understanding with instant feedback
Apply Bayes' Theorem to find if we are given: prior , likelihood , and evidence :
If two random variables and are statistically independent, what is their Covariance ?
The continuous probability curve characterized by its symmetrical 'bell curve' shape and governed by mean and variance is:
In a Multivariate Gaussian distribution, what geometric role does the Covariance Matrix play?
What is the mathematical relation between the standard deviation and variance of a random variable?
If events and are statistically independent, what is the joint probability equal to?
Which of the following describes the difference between a Probability Mass Function (PMF) and a Probability Density Function (PDF)?
In a Covariance Matrix , what does a positive off-diagonal value represent about feature variables and ?
The theorem stating that the sum of a large number of independent, identically distributed random variables will tend to follow a Gaussian (normal) distribution regardless of their original distribution shape is called:
In Bayesian inference, what does the 'Posterior' distribution represent?
Further Readings
Explore these highly recommended external references to deepen your understanding
