The Landscape of Probability Theory
Phase I: Foundations and Axioms
Intuition: Probability theory provides a framework for quantifying uncertainty, much like how you model failure rates or latency distributions in a distributed system. Events are observed system states; axioms are the inviolable invariants governing how we measure the likelihood of those states.
1. The Probability Space
- Formalism: A probability space is a triple .
* Sample Space (): The set of all possible outcomes of an experiment (e.g., all possible packet arrival times).
* Event Space (): A -algebra of subsets of . These are the events we can assign probabilities to.
* Probability Measure (): A function satisfying the Kolmogorov Axioms:
1. for any event .
2. .
3. Countable Additivity: If are disjoint events, then . - ML Application: Defines the fundamental rules for all stochastic models. Supervised learning estimates ; generative models estimate or .
2. Conditional Probability and Independence
- Intuition: Updating your belief about the system state given new logs. If Service A fails, does the probability of Service B failing increase? If not, they are independent.
- Formalism:
* Conditional Probability: , provided .
* Independence: Events and are independent iff . This implies .
* Chain Rule: . - ML Application:
* Conditional probability is the core of prediction: .
* Independence assumptions (often naive) drastically simplify model complexity (e.g., Naive Bayes).
* Chain rule is fundamental in sequence models (RNNs, Transformers) and Probabilistic Graphical Models (PGMs).
3. Bayes’ Theorem
- Intuition: The mechanism for debugging (inverse probability). Given an observed alert (Effect), what is the probability it was caused by a specific database failure (Cause)? It updates prior beliefs with new evidence.
- Formalism:
* : Posterior
* : Likelihood
* : Prior
* : Evidence (Marginal Likelihood), often calculated as .
- ML Application: The foundation of Bayesian Machine Learning. Treating model parameters as random variables and computing the posterior distribution .
Phase II: Random Variables and Distributions
Intuition: A Random Variable (RV) is a refactoring of raw outcomes into numerical data. Instead of handling the raw event “disk read error at sector X,” you map it to a metric io_errors = 1. A distribution is the histogram of that metric over time.
1. Random Variables (RVs)
- Formalism: An RV is a measurable function . It maps outcomes in the sample space to real numbers.
- ML Application: Features (inputs), labels (outputs), and sometimes model parameters are all treated as RVs.
2. Discrete vs. Continuous Distributions
- Formalism:
* Cumulative Distribution Function (CDF): . Defined for both discrete and continuous RVs.
* Discrete RV: Takes on a countable set of values. Characterized by a Probability Mass Function (PMF): .
* Continuous RV: Takes on an uncountable set of values. for any specific . Characterized by a Probability Density Function (PDF) , where:
- ML Application: Classification targets are discrete (PMF, e.g., Bernoulli/Categorical). Regression targets are continuous (PDF, e.g., Gaussian).
3. Expectation and Variance (Moments)
- Intuition: Expectation is the long-run average (e.g., average request/sec). Variance measures the jitter or instability around that average.
- Formalism:
* Expectation (): The first moment (mean).
* Discrete:
* Continuous:
* Linearity of Expectation: .
* Variance (): The second central moment.
*
* Standard Deviation (): . - ML Application: Loss functions are almost always expectations. Gradient descent relies on estimating . Variance is central to bias-variance tradeoff and regularization.
Phase III: Multivariate Distributions
Intuition: Analyzing a microservice architecture. You cannot understand the system by looking at only one service’s logs. You must model how services interact simultaneously. The joint distribution is the system snapshot; marginalization is filtering logs for a single service.
1. Joint Distributions
- Formalism: describes the simultaneous behavior of multiple RVs.
* Joint PMF: .
* Joint PDF: , where . - ML Application: A dataset with features is a sample from a -dimensional joint distribution. Most ML is about modeling .
2. Marginal and Conditional Distributions
- Formalism:
* Marginalization (Sum Rule): Recovering the distribution of a subset of variables by integrating/summing out the others.
*
*
* Conditional Distribution:
* - ML Application: Supervised learning directly models the conditional distribution . Marginalization is key in latent variable models (e.g., GMMs, VAEs) where we integrate out the latent state.
3. Covariance and Correlation
- Intuition: Normalized measurement of how two variables change together.
- Formalism:
* Covariance: .
* Correlation: . Values are in .
* Covariance Matrix (): For a random vector , is an symmetric, positive semi-definite matrix where . - ML Application: The covariance matrix defines the shape of the Multivariate Gaussian. PCA (Principal Component Analysis) is the eigendecomposition of the covariance matrix.
Phase IV: Key Distributions and Limit Theorems
Intuition: Standard library implementations for uncertainty. Gaussian is your default noise model. Bernoulli is your boolean. Poisson handles event rates.
1. Common Distributions
- Discrete:
* Bernoulli(): Single trial, success () with probability . (Binary classification).
* Binomial(): Number of successes in independent Bernoulli trials.
* Categorical(): Generalization of Bernoulli to outcomes (Multiclass classification).
* Poisson(): Number of events in a fixed interval given a constant mean rate . - Continuous:
* Uniform(): Constant probability density over . (Parameter initialization).
* Gaussian (Normal) : Bell curve. Defined by mean and variance .
* Multivariate Gaussian : The generalization to dimensions. Critical because linear combinations of Gaussians remain Gaussian, and its marginals/conditionals are also Gaussian.
* Beta() and Dirichlet(): Distributions over probabilities. Beta is over (conjugate prior for Bernoulli). Dirichlet is over the simplex (conjugate prior for Categorical).
2. Limit Theorems
- Intuition: Guarantees about aggregate system behavior.
- Formalism:
* Law of Large Numbers (LLN): The sample average converges to the expected value as the sample size .
* Central Limit Theorem (CLT): The sum (or average) of many independent, identically distributed (i.i.d.) RVs tends toward a Gaussian distribution, regardless of the original distribution.
- ML Application:
* LLN justifies using the training set average loss as a proxy for the true expected loss.
* CLT justifies the pervasive use of Gaussian noise models and L2 loss (MSE), as errors are often the sum of many small, independent factors.
Phase V: Information Theory and Estimation
Intuition: Information Theory quantifies “surprise” and is analogous to data compression—how many bits do you need to encode the system state? Estimation is reverse-engineering: given the logs (data), what were the most likely system parameters that produced them?
1. Information Theory
- Formalism:
* Entropy (): The average uncertainty or “surprise” in a RV.
* KL Divergence (): Also called Relative Entropy. Measures how different distribution is from a reference distribution . It is not symmetric and not a true distance metric.
* Cross-Entropy (): Average number of bits needed to identify an event from if we use a coding scheme optimized for .
- ML Application:
* Minimizing Cross-Entropy Loss is the standard objective function for classification. Since (the true data distribution) is fixed, minimizing Cross-Entropy is equivalent to minimizing KL Divergence between the true labels () and the model predictions ().
* KL Divergence is used in Variational Autoencoders (VAEs) and t-SNE.
2. Parameter Estimation
- Intuition: Fitting the model to the data.
- Formalism: given an i.i.d. dataset and a model with parameters .
* Maximum Likelihood Estimation (MLE): Find that maximizes the likelihood of observing the data.
In practice, we maximize the Log-Likelihood (turning the product into a sum):
* Maximum A Posteriori (MAP): incorporate a prior belief about the parameters.
- ML Application:
* MLE is the principle behind most loss functions. Minimizing Mean Squared Error (MSE) is equivalent to MLE assuming Gaussian noise. Minimizing Cross-Entropy is equivalent to MLE for Categorical/Bernoulli outputs.
* MAP is equivalent to MLE with Regularization. For example, L2 regularization (Ridge Regression) corresponds to assuming a Gaussian prior on the weights.