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!
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 the joint linear relationship between two random variables. If positive, they increase together; if negative, one increases as the other decreases.
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, we represent features as joint multivariate normal distributions. The Multivariate Gaussian PDF for a vector , with mean vector and a symmetric Covariance Matrix is:
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!
Interactive Practice Quiz
Test your understanding with instant feedback
