Skip to content
Kittycat.tech logo

LaTeX for Statistics and Probability

✅ Copy-ready LaTeX (MathJax) code for Statistics and Probability, organised from beginner to advanced, with where each formula is used in maths and in Machine Learning, AI and Data Science. 😻

New to LaTeX? Start with the LaTeX (MathJax) Basics for Greek letters, dots and spaces.

Just click the "copy code" button below 'markdown'!

Summary Overview ​

LevelSectionWhat you'll learnKey commands
Beginner1. Descriptive Statistics
1.1 Mean
1.2 Median and Mode
1.3 Variance and Standard Deviation
1.4 Standardisation (z-score)
1.5 Quartiles and Interquartile Range
1.6 Covariance and Correlation
summarising a dataset\bar{x}, \sigma, \operatorname{Cov}
Beginner2. Probability Basics
2.1 Probability Rules
2.2 Conditional Probability
2.3 Independence
2.4 Bayes' Theorem
2.5 Law of Total Probability
2.6 Permutations and Combinations
the rules of chanceP(A), \cup, \cap, \mid, \binom{}{}
Intermediate3. Random Variables and Distributions
3.1 Expected Value
3.2 Variance of a Random Variable
3.3 PMF, PDF and CDF
3.4 Bernoulli and Binomial Distributions
3.5 Poisson Distribution
3.6 Normal Distribution
3.7 Uniform and Exponential Distributions
3.8 Beta Distribution
modelling random outcomes\mathbb{E}, \sim, \mathcal{N}, \operatorname{Beta}
Intermediate4. Statistical Inference
4.1 Law of Large Numbers
4.2 Central Limit Theorem and Standard Error
4.3 Confidence Interval
4.4 Hypothesis Testing
4.5 p-value and Significance Level
4.6 Type I and Type II Errors
4.7 Chi-Squared Test
4.8 ANOVA (F-test)
4.9 Simple Linear Regression
drawing conclusions from samplesH_0, \pm, \chi^2, R^2
Advanced5. Markov Chains and Advanced Probability
5.1 Joint and Marginal Distributions
5.2 Conditional Expectation
5.3 Markov Property
5.4 Transition Matrix
5.5 Stationary Distribution
5.6 Markov's and Chebyshev's Inequalities
5.7 Markov Chain Monte Carlo
joint distributions and processes over time\pi, P^{n}, \min
Applied6. Probability for Machine Learning
6.1 Likelihood and Log-Likelihood
6.2 Maximum Likelihood Estimation
6.3 Posterior and MAP Estimation
6.4 Naive Bayes Classifier
6.5 Entropy and Cross-Entropy
6.6 KL Divergence
6.7 Multivariate Normal Distribution
how models learn from data\prod, \arg\max, \propto, D_{\mathrm{KL}}

1. Descriptive Statistics (Beginner) ​

1.1 Mean ​

Mean: "\bar{x}" and "\mu"

Example:

x¯=1n∑i=1nxiμ=1N∑i=1Nxix¯=2+4+4+4+5+5+7+98=5

x¯ is the mean of a sample, and μ is the mean of the whole population.

Where it's used: describing the centre of a dataset.

markdown
$$
\bar{x} = \frac{1}{n} \sum_{i=1}^{n} x_i \qquad \mu = \frac{1}{N} \sum_{i=1}^{N} x_i
$$

$$
\bar{x} = \frac{2 + 4 + 4 + 4 + 5 + 5 + 7 + 9}{8} = 5
$$

1.2 Median and Mode ​

Median: "\tilde{x}"

Example:

x~=x(n+12)(n odd){3,1,4,1,5}→{1,1,3,4,5}⇒x~=3,Mode=1

x(i) means the i-th value after sorting. With an even number of values, the median is the average of the two middle values.

Where it's used: describing the centre of skewed data, such as incomes, where the mean is pulled by extreme values.

markdown
$$
\tilde{x} = x_{\left( \frac{n+1}{2} \right)} \quad (n \text{ odd}) \qquad \{ 3, 1, 4, 1, 5 \} \to \{ 1, 1, 3, 4, 5 \} \;\Rightarrow\; \tilde{x} = 3, \; \operatorname{Mode} = 1
$$

1.3 Variance and Standard Deviation ​

Variance: "\sigma^2" and "s^2"

Example:

σ2=1N∑i=1N(xi−μ)2s2=1n−1∑i=1n(xi−x¯)2s=s2

σ2 is the population variance. For a sample, divide by n−1 instead of n.

Where it's used: describing how spread out the data is.

markdown
$$
\sigma^2 = \frac{1}{N} \sum_{i=1}^{N} (x_i - \mu)^2 \qquad s^2 = \frac{1}{n - 1} \sum_{i=1}^{n} (x_i - \bar{x})^2 \qquad s = \sqrt{s^2}
$$

1.4 Standardisation (z-score) ​

z-score: "\frac{x - \mu}{\sigma}"

Example:

z=x−μσz=85−7010=1.5

A z-score of 1.5 means the value is 1.5 standard deviations above the mean.

Where it's used: comparing values on different scales, and scaling features before training a model.

markdown
$$
z = \frac{x - \mu}{\sigma} \qquad z = \frac{85 - 70}{10} = 1.5
$$

1.5 Quartiles and Interquartile Range ​

Quartiles and IQR

Example:

IQR=Q3−Q1x<Q1−1.5IQRorx>Q3+1.5IQR

Q1 and Q3 are the 25th and 75th percentiles. Values outside these limits are usually treated as outliers.

Where it's used: box plots and finding outliers during data cleaning.

markdown
$$
\text{IQR} = Q_3 - Q_1 \qquad x < Q_1 - 1.5 \, \text{IQR} \quad \text{or} \quad x > Q_3 + 1.5 \, \text{IQR}
$$

1.6 Covariance and Correlation ​

Covariance and Correlation: "\operatorname{Cov}"

Example:

Cov(X,Y)=1n−1∑i=1n(xi−x¯)(yi−y¯)r=Cov(X,Y)sXsY

The correlation r is always between −1 and 1.

Where it's used: measuring how two features move together, and choosing features for a model.

markdown
$$
\operatorname{Cov}(X, Y) = \frac{1}{n - 1} \sum_{i=1}^{n} (x_i - \bar{x})(y_i - \bar{y}) \qquad r = \frac{\operatorname{Cov}(X, Y)}{s_X \, s_Y}
$$

2. Probability Basics (Beginner) ​

2.1 Probability Rules ​

Complement and Union Rules

Example:

0≤P(A)≤1P(Ac)=1−P(A)P(A∪B)=P(A)+P(B)−P(A∩B)

Ac is the complement of A, meaning "A does not happen".

Where it's used: calculating the chance of "not" and "or" events.

markdown
$$
0 \le P(A) \le 1 \qquad P(A^{c}) = 1 - P(A) \qquad P(A \cup B) = P(A) + P(B) - P(A \cap B)
$$

2.2 Conditional Probability ​

Conditional Probability: "\mid"

Example:

P(A∣B)=P(A∩B)P(B)

Use \mid instead of | for the correct spacing. It reads "the probability of A given B".

Where it's used: updating a probability after new information arrives.

markdown
$$
P(A \mid B) = \frac{P(A \cap B)}{P(B)}
$$

2.3 Independence ​

Independent Events

Example:

P(A∩B)=P(A)P(B)

Two events are independent when knowing one tells you nothing about the other.

Where it's used: simplifying calculations, and the main assumption behind Naive Bayes.

markdown
$$
P(A \cap B) = P(A) \, P(B)
$$

2.4 Bayes' Theorem ​

Bayes' Theorem

Example:

P(A∣B)=P(B∣A)P(A)P(B)

Where it's used: spam filters, medical test results, Naive Bayes classifiers and Bayesian statistics.

markdown
$$
P(A \mid B) = \frac{P(B \mid A) \, P(A)}{P(B)}
$$

2.5 Law of Total Probability ​

Law of Total Probability

Example:

P(B)=∑iP(B∣Ai)P(Ai)

The events Ai must cover every possibility without overlapping.

Where it's used: finding the denominator P(B) in Bayes' theorem.

markdown
$$
P(B) = \sum_{i} P(B \mid A_i) \, P(A_i)
$$

2.6 Permutations and Combinations ​

Combinations: "\binom{n}{k}"

Example:

P(n,k)=n!(n−k)!(nk)=n!k!(n−k)!(52)=10

Use permutations when order matters and combinations when it does not.

Where it's used: counting outcomes, and the binomial distribution.

markdown
$$
P(n, k) = \frac{n!}{(n - k)!} \qquad \binom{n}{k} = \frac{n!}{k! \, (n - k)!} \qquad \binom{5}{2} = 10
$$

3. Random Variables and Distributions (Intermediate) ​

3.1 Expected Value ​

Expected Value: "\mathbb{E}"

Example:

E[X]=∑xxP(X=x)E[X]=∫−∞∞xf(x)dx

Use the sum for discrete variables and the integral for continuous ones.

Where it's used: the average outcome of a random variable, such as the expected loss of a model.

markdown
$$
\mathbb{E}[X] = \sum_{x} x \, P(X = x) \qquad \mathbb{E}[X] = \int_{-\infty}^{\infty} x \, f(x) \, dx
$$

3.2 Variance of a Random Variable ​

Variance: "\operatorname{Var}"

Example:

Var(X)=E[(X−μ)2]=E[X2]−(E[X])2

The second form is usually quicker to calculate.

Where it's used: measuring the uncertainty of a prediction or an estimate.

markdown
$$
\operatorname{Var}(X) = \mathbb{E}\big[ (X - \mu)^2 \big] = \mathbb{E}[X^2] - \big( \mathbb{E}[X] \big)^2
$$

3.3 PMF, PDF and CDF ​

Probability Functions

Example:

p(x)=P(X=x)F(x)=P(X≤x)=∫−∞xf(t)dt

p(x) is the probability mass function for discrete variables, f(x) is the probability density function for continuous ones, and F(x) is the cumulative distribution function.

Where it's used: describing any probability distribution.

markdown
$$
p(x) = P(X = x) \qquad F(x) = P(X \le x) = \int_{-\infty}^{x} f(t) \, dt
$$

3.4 Bernoulli and Binomial Distributions ​

Binomial: "X \sim \operatorname{Bin}(n, p)"

Example:

X∼Bin(n,p)P(X=k)=(nk)pk(1−p)n−kE[X]=npVar(X)=np(1−p)

A Bernoulli variable is a single yes or no trial, the binomial with n=1. For example, with n=5 and p=0.5, P(X=2)=1032=0.3125.

Where it's used: counting successes, such as clicks, conversions and correct predictions.

markdown
$$
X \sim \operatorname{Bin}(n, p) \qquad P(X = k) = \binom{n}{k} p^{k} (1 - p)^{n - k}
$$

$$
\mathbb{E}[X] = np \qquad \operatorname{Var}(X) = np(1 - p)
$$

3.5 Poisson Distribution ​

Poisson Distribution

Example:

X∼Poisson(λ)P(X=k)=λke−λk!E[X]=Var(X)=λ

Where it's used: counting events in a fixed time, such as website visits per hour or emails per day.

markdown
$$
X \sim \operatorname{Poisson}(\lambda) \qquad P(X = k) = \frac{\lambda^{k} e^{-\lambda}}{k!} \qquad \mathbb{E}[X] = \operatorname{Var}(X) = \lambda
$$

3.6 Normal Distribution ​

Normal Distribution: "\mathcal{N}"

Example:

X∼N(μ,σ2)f(x)=1σ2πe−(x−μ)22σ2Z∼N(0,1)

\sim reads as "is distributed as". Z is the standard normal distribution.

Where it's used: modelling data, hypothesis testing and initialising neural network weights.

markdown
$$
X \sim \mathcal{N}(\mu, \sigma^2) \qquad f(x) = \frac{1}{\sigma \sqrt{2\pi}} \, e^{-\frac{(x - \mu)^2}{2\sigma^2}} \qquad Z \sim \mathcal{N}(0, 1)
$$

3.7 Uniform and Exponential Distributions ​

Uniform and Exponential

Example:

X∼U(a,b),f(x)=1b−aX∼Exp(λ),f(x)=λe−λx,x≥0

The exponential distribution has mean 1λ.

Where it's used: random initialisation and sampling (uniform), and waiting times between events (exponential).

markdown
$$
X \sim U(a, b), \quad f(x) = \frac{1}{b - a} \qquad X \sim \operatorname{Exp}(\lambda), \quad f(x) = \lambda e^{-\lambda x}, \; x \ge 0
$$

3.8 Beta Distribution ​

Beta Distribution: "\operatorname{Beta}(\alpha, \beta)"

Example:

X∼Beta(α,β)f(x)=xα−1(1−x)β−1B(α,β),0≤x≤1E[X]=αα+βprior Beta(α,β)+k successes in n trials⇒posterior Beta(α+k,β+n−k)

The Beta distribution describes an unknown probability, so its values are between 0 and 1. B(α,β) is the Beta function, which makes the total area 1.

Where it's used: Bayesian A/B testing, and Thompson sampling in recommender systems and reinforcement learning.

markdown
$$
X \sim \operatorname{Beta}(\alpha, \beta) \qquad f(x) = \frac{x^{\alpha - 1} (1 - x)^{\beta - 1}}{B(\alpha, \beta)}, \; 0 \le x \le 1 \qquad \mathbb{E}[X] = \frac{\alpha}{\alpha + \beta}
$$

$$
\text{prior } \operatorname{Beta}(\alpha, \beta) \;+\; k \text{ successes in } n \text{ trials} \;\Rightarrow\; \text{posterior } \operatorname{Beta}(\alpha + k, \; \beta + n - k)
$$

4. Statistical Inference (Intermediate) ​

4.1 Law of Large Numbers ​

Law of Large Numbers

Example:

X¯n=1n∑i=1nXi→μas n→∞limn→∞P(|X¯n−μ|>ε)=0

As the sample gets bigger, the sample mean gets closer to the true mean μ. The second form says this happens for any small gap ε.

Where it's used: the reason averages from large datasets are reliable, and Monte Carlo simulation.

markdown
$$
\bar{X}_n = \frac{1}{n} \sum_{i=1}^{n} X_i \to \mu \quad \text{as } n \to \infty \qquad \lim_{n \to \infty} P\big( \lvert \bar{X}_n - \mu \rvert > \varepsilon \big) = 0
$$

4.2 Central Limit Theorem and Standard Error ​

Central Limit Theorem

Example:

X¯≈N(μ,σ2n)SE=σn

For a large sample, the sample mean is approximately normal, whatever the shape of the original data.

Where it's used: the reason confidence intervals and many tests work.

markdown
$$
\bar{X} \approx \mathcal{N}\left( \mu, \frac{\sigma^2}{n} \right) \qquad \text{SE} = \frac{\sigma}{\sqrt{n}}
$$

4.3 Confidence Interval ​

Confidence Interval: "\pm"

Example:

x¯±zα/2σn95% CI:x¯±1.96σn

Write \% for the percent sign, because % starts a comment in LaTeX.

Where it's used: reporting an estimate with its uncertainty, such as model accuracy across test sets.

markdown
$$
\bar{x} \pm z_{\alpha/2} \, \frac{\sigma}{\sqrt{n}} \qquad 95\% \text{ CI}: \; \bar{x} \pm 1.96 \, \frac{\sigma}{\sqrt{n}}
$$

4.4 Hypothesis Testing ​

Hypotheses: "H_0" and "H_1"

Example:

H0:μ=μ0vsH1:μ≠μ0z=x¯−μ0σ/nt=x¯−μ0s/n

Use z when σ is known and t (with n−1 degrees of freedom) when you only have the sample standard deviation s.

Where it's used: A/B testing, and checking whether a new model is really better than the old one.

markdown
$$
H_0: \mu = \mu_0 \quad \text{vs} \quad H_1: \mu \neq \mu_0 \qquad z = \frac{\bar{x} - \mu_0}{\sigma / \sqrt{n}} \qquad t = \frac{\bar{x} - \mu_0}{s / \sqrt{n}}
$$

4.5 p-value and Significance Level ​

p-value

Example:

p=P(|Z|≥|z|∣H0)reject H0 if p<α

This is a two-sided test. α is usually 0.05.

Where it's used: deciding whether a result is statistically significant.

markdown
$$
p = P\big( \lvert Z \rvert \ge \lvert z \rvert \mid H_0 \big) \qquad \text{reject } H_0 \text{ if } p < \alpha
$$

4.6 Type I and Type II Errors ​

Errors and Power

Example:

α=P(reject H0∣H0 true)β=P(fail to reject H0∣H0 false)Power=1−β

A Type I error is a false positive and a Type II error is a false negative. Power is the chance of detecting a real effect.

Where it's used: planning sample sizes for experiments and A/B tests.

markdown
$$
\alpha = P(\text{reject } H_0 \mid H_0 \text{ true}) \qquad \beta = P(\text{fail to reject } H_0 \mid H_0 \text{ false}) \qquad \text{Power} = 1 - \beta
$$

4.7 Chi-Squared Test ​

Chi-Squared: "\chi^2"

Example:

χ2=∑i(Oi−Ei)2Ei

Oi are the observed counts and Ei are the expected counts.

Where it's used: testing whether two categorical variables are related, such as in feature selection.

markdown
$$
\chi^2 = \sum_{i} \frac{(O_i - E_i)^2}{E_i}
$$

4.8 ANOVA (F-test) ​

One-Way ANOVA

Example:

F=MSbetweenMSwithin=∑j=1knj(x¯j−x¯)2/(k−1)∑j=1k∑i=1nj(xij−x¯j)2/(N−k)

k is the number of groups, nj is the size of group j, and N is the total number of values. A large F means the group means really differ.

Where it's used: comparing three or more groups at once, such as several model versions or marketing campaigns.

markdown
$$
F = \frac{\text{MS}_{\text{between}}}{\text{MS}_{\text{within}}} = \frac{\sum_{j=1}^{k} n_j (\bar{x}_j - \bar{x})^2 \, / \, (k - 1)}{\sum_{j=1}^{k} \sum_{i=1}^{n_j} (x_{ij} - \bar{x}_j)^2 \, / \, (N - k)}
$$

4.9 Simple Linear Regression ​

Least Squares Line

Example:

y^=β0+β1xβ1=∑i(xi−x¯)(yi−y¯)∑i(xi−x¯)2β0=y¯−β1x¯R2=1−∑i(yi−y^i)2∑i(yi−y¯)2

R2 is the share of the variation in y that the line explains.

Where it's used: predicting one variable from another, the starting point of Machine Learning.

markdown
$$
\hat{y} = \beta_0 + \beta_1 x \qquad \beta_1 = \frac{\sum_{i} (x_i - \bar{x})(y_i - \bar{y})}{\sum_{i} (x_i - \bar{x})^2} \qquad \beta_0 = \bar{y} - \beta_1 \bar{x}
$$

$$
R^2 = 1 - \frac{\sum_{i} (y_i - \hat{y}_i)^2}{\sum_{i} (y_i - \bar{y})^2}
$$

5. Markov Chains and Advanced Probability (Advanced) ​

5.1 Joint and Marginal Distributions ​

Joint and Marginal Distributions

Example:

p(x)=∑yp(x,y)fX(x)=∫−∞∞f(x,y)dy

Where it's used: working with several random variables at once, such as features and labels.

markdown
$$
p(x) = \sum_{y} p(x, y) \qquad f_X(x) = \int_{-\infty}^{\infty} f(x, y) \, dy
$$

5.2 Conditional Expectation ​

Conditional Expectation: "\mathbb{E}[X \mid Y]"

Example:

E[X∣Y=y]=∑xxP(X=x∣Y=y)E[X]=E[E[X∣Y]]

The second formula is the law of total expectation: average the conditional averages to get the overall average.

Where it's used: regression, which predicts E[Y∣X], and value functions in reinforcement learning.

markdown
$$
\mathbb{E}[X \mid Y = y] = \sum_{x} x \, P(X = x \mid Y = y) \qquad \mathbb{E}[X] = \mathbb{E}\big[ \mathbb{E}[X \mid Y] \big]
$$

5.3 Markov Property ​

Markov Property

Example:

P(Xt+1=j∣Xt=i,Xt−1,…,X0)=P(Xt+1=j∣Xt=i)

The next state depends only on the current state, not on the whole history.

Where it's used: modelling processes that move between states, such as weather, customer behaviour and text.

markdown
$$
P(X_{t+1} = j \mid X_t = i, X_{t-1}, \ldots, X_0) = P(X_{t+1} = j \mid X_t = i)
$$

5.4 Transition Matrix ​

Transition Matrix

Example:

pij=P(Xt+1=j∣Xt=i)P=[0.90.10.50.5]P(n)=Pn

Each row adds up to 1. In this example, state 1 is "sunny" and state 2 is "rainy". Pn gives the probabilities after n steps.

Where it's used: PageRank, weather models and customer journeys.

markdown
$$
p_{ij} = P(X_{t+1} = j \mid X_t = i) \qquad P = \begin{bmatrix} 0.9 & 0.1 \\ 0.5 & 0.5 \end{bmatrix} \qquad P^{(n)} = P^{n}
$$

5.5 Stationary Distribution ​

Stationary Distribution: "\boldsymbol{\pi}"

Example:

π=πP,∑iπi=1π=(56,16)

For the transition matrix above, the chain spends 56 of the time sunny in the long run. Finding π is an eigenvector problem, so it links to Linear Algebra.

Where it's used: long-run behaviour of a Markov chain, and PageRank.

markdown
$$
\boldsymbol{\pi} = \boldsymbol{\pi} P, \qquad \sum_{i} \pi_i = 1 \qquad \boldsymbol{\pi} = \left( \frac{5}{6}, \frac{1}{6} \right)
$$

5.6 Markov's and Chebyshev's Inequalities ​

Markov's and Chebyshev's Inequalities

Example:

P(X≥a)≤E[X]a(X≥0,a>0)P(|X−μ|≥kσ)≤1k2

These give limits on probabilities using only the mean and the variance.

Where it's used: proving how fast algorithms converge, and bounds in learning theory.

markdown
$$
P(X \ge a) \le \frac{\mathbb{E}[X]}{a} \quad (X \ge 0, \; a > 0) \qquad P\big( \lvert X - \mu \rvert \ge k\sigma \big) \le \frac{1}{k^2}
$$

5.7 Markov Chain Monte Carlo ​

Metropolis-Hastings Acceptance

Example:

A(x→x′)=min(1,p(x′)q(x∣x′)p(x)q(x′∣x))

p is the target distribution and q is the proposal distribution. Accepted moves form a Markov chain whose stationary distribution is p.

Where it's used: Bayesian statistics, when the posterior is too complex to calculate directly.

markdown
$$
A(x \to x') = \min\left( 1, \; \frac{p(x') \, q(x \mid x')}{p(x) \, q(x' \mid x)} \right)
$$

6. Probability for Machine Learning (Applied) ​

6.1 Likelihood and Log-Likelihood ​

Likelihood

Example:

L(θ)=∏i=1np(xi∣θ)ℓ(θ)=log⁡L(θ)=∑i=1nlog⁡p(xi∣θ)

Taking the log turns a product into a sum, which is easier to work with.

Where it's used: measuring how well model parameters θ explain the data.

markdown
$$
L(\theta) = \prod_{i=1}^{n} p(x_i \mid \theta) \qquad \ell(\theta) = \log L(\theta) = \sum_{i=1}^{n} \log p(x_i \mid \theta)
$$

6.2 Maximum Likelihood Estimation ​

MLE

Example:

θ^MLE=arg⁡maxθ∑i=1nlog⁡p(xi∣θ)

Minimising cross-entropy loss is the same as maximising the log-likelihood.

Where it's used: training most machine learning models.

markdown
$$
\hat{\theta}_{\text{MLE}} = \underset{\theta}{\arg\max} \; \sum_{i=1}^{n} \log p(x_i \mid \theta)
$$

6.3 Posterior and MAP Estimation ​

Posterior: "\propto"

Example:

p(θ∣D)∝p(D∣θ)p(θ)θ^MAP=arg⁡maxθp(D∣θ)p(θ)

Posterior is proportional to likelihood times prior. A prior on the weights acts like regularisation.

Where it's used: Bayesian machine learning and regularised models.

markdown
$$
p(\theta \mid D) \propto p(D \mid \theta) \, p(\theta) \qquad \hat{\theta}_{\text{MAP}} = \underset{\theta}{\arg\max} \; p(D \mid \theta) \, p(\theta)
$$

6.4 Naive Bayes Classifier ​

Naive Bayes

Example:

y^=arg⁡maxkP(Ck)∏i=1dP(xi∣Ck)

It assumes the features are independent given the class.

Where it's used: text classification and spam filtering.

markdown
$$
\hat{y} = \underset{k}{\arg\max} \; P(C_k) \prod_{i=1}^{d} P(x_i \mid C_k)
$$

6.5 Entropy and Cross-Entropy ​

Entropy

Example:

H(p)=−∑xp(x)log⁡p(x)H(p,q)=−∑xp(x)log⁡q(x)

Where it's used: measuring uncertainty, decision tree splits, and the cross-entropy loss for classification.

markdown
$$
H(p) = -\sum_{x} p(x) \log p(x) \qquad H(p, q) = -\sum_{x} p(x) \log q(x)
$$

6.6 KL Divergence ​

KL Divergence: "D_{\mathrm{KL}}"

Example:

DKL(P∥Q)=∑xP(x)log⁡P(x)Q(x)

It measures how different Q is from P. It is always at least 0, and it is not symmetric.

Where it's used: variational autoencoders, knowledge distillation and fine-tuning large language models.

markdown
$$
D_{\mathrm{KL}}(P \parallel Q) = \sum_{x} P(x) \log \frac{P(x)}{Q(x)}
$$

6.7 Multivariate Normal Distribution ​

Multivariate Normal

Example:

x∼N(μ,Σ)f(x)=1(2π)d/2|Σ|1/2exp⁡(−12(x−μ)⊤Σ−1(x−μ))

Σ is the covariance matrix and |Σ| is its determinant.

Where it's used: Gaussian processes, Gaussian mixture models and anomaly detection.

markdown
$$
\mathbf{x} \sim \mathcal{N}(\boldsymbol{\mu}, \Sigma) \qquad f(\mathbf{x}) = \frac{1}{(2\pi)^{d/2} \lvert \Sigma \rvert^{1/2}} \exp\left( -\frac{1}{2} (\mathbf{x} - \boldsymbol{\mu})^{\top} \Sigma^{-1} (\mathbf{x} - \boldsymbol{\mu}) \right)
$$

✅Summarized reviews based on Kittycat's insights from the best online courses at top universities