Guide To AI LogoGuide To AI
Unit 10

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 98%98\% likely to be a cat').

Conditional Probability (P(AB)P(A | B)): The probability of event AA occurring, given that event BB has already occurred: P(AB)=P(AB)P(B)P(A | B) = \frac{P(A \cap B)}{P(B)}

Statistical Independence: Events AA and BB are independent if the occurrence of BB does not affect the probability of AA, meaning P(AB)=P(A)P(A | B) = P(A) or equivalently P(AB)=P(A)P(B)P(A \cap B) = P(A)P(B).

Bayes' Theorem (Bayesian Inference): The mathematical bedrock of probabilistic machine learning. It allows us to update our prior belief about an event (P(A)P(A)) after observing new evidence (BB). It maps the relationship between prior, likelihood, evidence, and posterior: P(AB)=P(BA)P(A)P(B)P(A | B) = \frac{P(B | A) P(A)}{P(B)}

Spam Filter Trace: Let's calculate whether an incoming email containing the word *free* (FF) is actually *spam* (SS): - Prior belief: 30%30\% of all emails are spam: P(S)=0.30P(S) = 0.30. - Likelihood: 80%80\% of spam emails contain the word *free*: P(FS)=0.80P(F | S) = 0.80. - General Evidence: 40%40\% of all emails contain the word *free*: P(F)=0.40P(F) = 0.40. - Applying Bayes' Theorem: P(SF)=P(FS)P(S)P(F)=0.80×0.300.40=0.240.40=0.60P(S | F) = \frac{P(F | S) P(S)}{P(F)} = \frac{0.80 \times 0.30}{0.40} = \frac{0.24}{0.40} = 0.60 This calculation proves that observing the word *free* updates our belief from 30%30\% prior to a 60%60\% 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 (E[X]E[X]): The theoretical mean or average value of a random variable over infinite trials. For discrete variables, it is: E[X]=xxP(X=x)E[X] = \sum_{x} x P(X = x),

Variance (Var(X)\text{Var}(X)): Measures how spread out the values are from their mean value: Var(X)=E[(XE[X])2]=E[X2](E[X])2\text{Var}(X) = E[(X - E[X])^2] = E[X^2] - (E[X])^2,

Discrete Dice Trace: Let's calculate the expectation and variance of rolling a fair 4-sided die (X{1,2,3,4}X \in \{1, 2, 3, 4\}, each with probability 0.250.25): - Expectation E[X]E[X]: E[X]=(1)(0.25)+(2)(0.25)+(3)(0.25)+(4)(0.25)=2.5E[X] = (1)(0.25) + (2)(0.25) + (3)(0.25) + (4)(0.25) = 2.5 - Expected Squared Value E[X2]E[X^2]: E[X2]=(12)(0.25)+(22)(0.25)+(32)(0.25)+(42)(0.25)=0.25+1.0+2.25+4.0=7.5E[X^2] = (1^2)(0.25) + (2^2)(0.25) + (3^2)(0.25) + (4^2)(0.25) = 0.25 + 1.0 + 2.25 + 4.0 = 7.5 - Variance Var(X)\text{Var}(X): Var(X)=E[X2](E[X])2=7.52.52=7.56.25=1.25\text{Var}(X) = E[X^2] - (E[X])^2 = 7.5 - 2.5^2 = 7.5 - 6.25 = 1.25 This gives us a precise mathematical measure of the spread of the die's outcomes!

Covariance (Cov(X,Y)\text{Cov}(X, Y)): 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 μ\mu and variance σ2\sigma^2 is: f(x)=1σ2πe(xμ)22σ2f(x) = \frac{1}{\sigma \sqrt{2\pi}} e^{-\frac{(x - \mu)^2}{2\sigma^2}}

In high-dimensional spaces, we represent features as joint multivariate normal distributions. The Multivariate Gaussian PDF for a vector xRdx \in \mathbb{R}^d, with mean vector μ\mu and a symmetric d×dd \times d Covariance Matrix Σ\Sigma is: f(x)=1(2π)d/2Σ1/2e12(xμ)2Σ1(xμ)f(x) = \frac{1}{(2\pi)^{d/2} |\Sigma|^{1/2}} e^{-\frac{1}{2} (x - \mu)^2 \Sigma^{-1} (x - \mu)}

where Σ|\Sigma| is the determinant of the covariance matrix. Geometrically, the mean vector μ\mu translates the center of the distribution in space, while the covariance matrix Σ\Sigma scales and rotates the probability density ellipses. The eigenvalues of Σ\Sigma represent the variance scales along those rotated principal axes!

Interactive Practice Quiz

Test your understanding with instant feedback

QUESTION 01

Apply Bayes' Theorem to find P(AB)P(A|B) if we are given: prior P(A)=0.20P(A) = 0.20, likelihood P(BA)=0.80P(B|A) = 0.80, and evidence P(B)=0.40P(B) = 0.40:

QUESTION 02

If two random variables XX and YY are statistically independent, what is their Covariance Cov(X,Y)\text{Cov}(X, Y)?

QUESTION 03

The continuous probability curve characterized by its symmetrical 'bell curve' shape and governed by mean μ\mu and variance σ2\sigma^2 is:

QUESTION 04

In a Multivariate Gaussian distribution, what geometric role does the d×dd \times d Covariance Matrix Σ\Sigma play?

QUESTION 05

What is the mathematical relation between the standard deviation σ\sigma and variance Var(X)\text{Var}(X) of a random variable?

QUESTION 06

If events AA and BB are statistically independent, what is the joint probability P(AB)P(A \cap B) equal to?

QUESTION 07

Which of the following describes the difference between a Probability Mass Function (PMF) and a Probability Density Function (PDF)?

QUESTION 08

In a Covariance Matrix Σ\Sigma, what does a positive off-diagonal value Σij>0\Sigma_{ij} > 0 represent about feature variables ii and jj?

QUESTION 09

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:

QUESTION 10

In Bayesian inference, what does the 'Posterior' distribution P(AB)P(A|B) represent?