This appendix gathers, in one place, the probability and statistics that the chapters of Building Temporal AI assume and reuse. It is a refresher, not a first course: it states the definitions, the identities, and the formulas that recur, and it points each one to the chapter where it does its work. Read it once now to calibrate notation, then return to it as a lookup table when a chapter writes a likelihood, a posterior, or a test statistic and assumes you can read it. Everything here is written for the temporal setting, so a random variable is usually one slice of a sequence, an expectation is usually taken over a stochastic process, and a Gaussian is usually the belief a filter carries about a hidden state.
Temporal AI is probabilistic to its core. A forecast is a conditional distribution over the future given the past; a filter is a posterior over a hidden state; a sequence model factorizes a joint distribution with the chain rule; a fitted ARIMA, GARCH, Kalman, or variational model is a maximized likelihood; a stationarity verdict is a hypothesis test. Five ideas carry almost all of that weight: random variables and their distributions, conditioning and Bayes theorem, maximum likelihood estimation, hypothesis testing, and the multivariate Gaussian with its conditioning formula. This appendix develops exactly those five, in that order, with the notation conventions of Appendix A.
1. Random Variables, Distributions, and Their Moments
A random variable assigns numbers to the outcomes of a random experiment. A discrete random variable $X$ takes values in a countable set and is described by its probability mass function $p_X(x) = \Pr(X = x)$, with $p_X(x) \ge 0$ and $\sum_x p_X(x) = 1$. A continuous random variable is described by its probability density function $f_X(x) \ge 0$, which integrates to one, $\int_{-\infty}^{\infty} f_X(x)\,dx = 1$, and whose probabilities come from areas, $\Pr(a \le X \le b) = \int_a^b f_X(x)\,dx$. Both kinds share a cumulative distribution function $F_X(x) = \Pr(X \le x)$, non-decreasing from $0$ to $1$, which is the running sum or integral of the mass or density. In a time series, $X$ is typically the value $x_t$ of the series at one time step, and the whole point of Part II and Part III is to model how the distribution of $x_t$ depends on the past.
The two summary moments used everywhere are the expectation and the variance. The expectation, or mean, is the probability-weighted average
$$\mathbb{E}[X] = \sum_x x\, p_X(x) \quad\text{(discrete)}, \qquad \mathbb{E}[X] = \int_{-\infty}^{\infty} x\, f_X(x)\, dx \quad\text{(continuous)},$$and expectation is linear, $\mathbb{E}[aX + bY + c] = a\,\mathbb{E}[X] + b\,\mathbb{E}[Y] + c$, with no independence required. The variance measures spread around the mean,
$$\operatorname{Var}(X) = \mathbb{E}\!\big[(X - \mathbb{E}[X])^2\big] = \mathbb{E}[X^2] - \big(\mathbb{E}[X]\big)^2,$$and its square root is the standard deviation $\sigma_X$. For two variables the covariance generalizes the variance,
$$\operatorname{Cov}(X, Y) = \mathbb{E}\!\big[(X - \mathbb{E}[X])(Y - \mathbb{E}[Y])\big] = \mathbb{E}[XY] - \mathbb{E}[X]\,\mathbb{E}[Y],$$and its scale-free version is the Pearson correlation $\rho_{X,Y} = \operatorname{Cov}(X, Y) / (\sigma_X \sigma_Y)$, which lies in $[-1, 1]$. Setting $Y$ to a lagged copy of $X$ turns the covariance into the autocovariance and the correlation into the autocorrelation, the diagnostic that organizes the stationarity and model-identification work of Chapter 3 and Chapter 5.
A handful of named distributions recur throughout. The Gaussian (normal) $\mathcal{N}(\mu, \sigma^2)$, with density $f(x) = (2\pi\sigma^2)^{-1/2}\exp\!\big(-(x-\mu)^2 / (2\sigma^2)\big)$, models innovations, measurement noise, and the beliefs every Kalman filter and most deep latent-variable models carry. The Bernoulli $\operatorname{Ber}(p)$ and its sum the Binomial $\operatorname{Bin}(n, p)$, with $\mathbb{E}=np$ and $\operatorname{Var}=np(1-p)$, model binary events and counts of successes, the substrate of event and classification heads. The Poisson $\operatorname{Pois}(\lambda)$, with mass $e^{-\lambda}\lambda^k / k!$ and $\mathbb{E}=\operatorname{Var}=\lambda$, models event counts in a window and underlies the point processes of Chapter 18. The exponential $\operatorname{Exp}(\lambda)$, density $\lambda e^{-\lambda x}$, models the waiting time between such events. The Student-t, heavier-tailed than the Gaussian, models the fat-tailed financial returns of Chapter 6 and gives robust likelihoods that downweight outliers.
2. Conditional Probability, Independence, Bayes Theorem, and the Chain Rule
Conditioning is the act of updating a distribution once you learn something, and it is the single most important operation in this book. The conditional probability of $A$ given $B$ is
$$\Pr(A \mid B) = \frac{\Pr(A \cap B)}{\Pr(B)}, \qquad \Pr(B) > 0,$$and the conditional density $f_{X \mid Y}(x \mid y) = f_{X,Y}(x, y) / f_Y(y)$ is its continuous twin. Two variables are independent when conditioning changes nothing, $\Pr(A \cap B) = \Pr(A)\Pr(B)$, equivalently $f_{X,Y}(x,y) = f_X(x) f_Y(y)$; in the temporal setting the weaker and more useful notion is the Markov property, that the future is independent of the distant past given the present state, which is the assumption that makes filtering and state-space modeling tractable.
Rearranging the definition of conditional probability two ways and equating them gives Bayes theorem, the engine of every posterior in the book:
$$\underbrace{p(\theta \mid y)}_{\text{posterior}} = \frac{\overbrace{p(y \mid \theta)}^{\text{likelihood}}\;\overbrace{p(\theta)}^{\text{prior}}}{\underbrace{p(y)}_{\text{evidence}}}, \qquad p(y) = \int p(y \mid \theta)\, p(\theta)\, d\theta.$$Read it as a rule for turning a prior belief about an unknown $\theta$ into a posterior belief after seeing data $y$, with the likelihood doing the updating and the evidence $p(y)$ a normalizing constant. The chain rule (also called the product rule) factorizes any joint distribution into a product of conditionals,
$$p(x_1, x_2, \ldots, x_T) = p(x_1)\prod_{t=2}^{T} p(x_t \mid x_1, \ldots, x_{t-1}),$$
and this factorization is the literal definition of an autoregressive sequence model: each factor $p(x_t \mid x_{
The recursive Bayesian filter of Chapter 7 is nothing more than Bayes theorem applied once per time step: predict rolls the posterior forward through the transition model (a marginalization), and update folds in the new measurement through the likelihood (a Bayes update). The same chain-rule factorization that defines an autoregressive language model defines an ARIMA model and a Decision Transformer. When you see the chain rule, Bayes theorem, and the Markov property used together, you are looking at the mathematical skeleton shared by the Kalman filter, the HMM, the RNN, and the Transformer. The route from one to the next is the temporal thread of this book; see the Table of Contents to follow it from Chapter 7 forward.
An estimator $\hat{\theta}$ is a function of the data that approximates an unknown parameter $\theta$. Three properties grade it. Its bias is $\operatorname{Bias}(\hat\theta) = \mathbb{E}[\hat\theta] - \theta$, the systematic error; its variance is $\operatorname{Var}(\hat\theta)$, the noise across hypothetical resamples; and the mean squared error decomposes cleanly into the two,
This bias-variance decomposition is the lens through which the book reads overfitting, regularization, and ensembling. An estimator is consistent when it converges in probability to the truth as the sample grows, $\hat\theta_n \xrightarrow{p} \theta$, the asymptotic guarantee that justifies trusting a long-series fit.
The workhorse estimator is maximum likelihood. Given data $y = (y_1, \ldots, y_n)$ and a model $p(y \mid \theta)$, the likelihood $L(\theta) = p(y \mid \theta)$ is read as a function of $\theta$ for fixed data, and the maximum likelihood estimate maximizes it. Because products underflow and sums differentiate cleanly, one maximizes the log-likelihood instead,
where the sum form assumes independent observations; for dependent time series the chain rule of Section 2 replaces it with a sum of one-step-ahead conditional log-densities $\sum_t \log p(y_t \mid y_{
The cleanest closed-form maximum likelihood estimate is for a Gaussian: the MLE of the mean is the sample mean and the MLE of the variance is the (biased) sample variance. The snippet below confirms both numerically and then recovers the same mean by directly maximizing the log-likelihood with a numerical optimizer, the route every model in the book takes when no closed form exists.
Bayesian estimation keeps the whole posterior rather than collapsing to a single point. Instead of maximizing the likelihood, it combines the likelihood with a prior $p(\theta)$ through Bayes theorem and reports the posterior $p(\theta \mid y)$, from which any quantity (a posterior mean, a credible interval, a predictive distribution) follows by integration. The prior encodes belief before the data and regularizes the estimate when data are scarce; the maximum a posteriori estimate $\hat\theta_{\text{MAP}} = \arg\max_\theta\, [\log p(y \mid \theta) + \log p(\theta)]$ is the bridge back to maximum likelihood, recovering it exactly under a flat prior, and a Gaussian prior on weights reappears as $L_2$ regularization. Bayesian forecasting, priors, and the full posterior predictive distribution are developed in Chapter 19; see the Table of Contents for the probabilistic-forecasting arc.
A hypothesis test asks whether the data are consistent with a null hypothesis $H_0$. One computes a test statistic, derives its distribution under $H_0$, and reports a $p$-value, the probability under $H_0$ of a statistic at least as extreme as the one observed; a small $p$-value is evidence against $H_0$. The $t$-test compares means using a statistic that follows a Student-t distribution under the null, and the $F$-test compares variances or nested-model fits using a statistic that follows an $F$ distribution; both underlie regression coefficient significance and the model-comparison tests scattered through Part II. The cardinal warning is multiple testing: if you run $m$ independent tests at level $\alpha$, the chance of at least one false positive is $1 - (1-\alpha)^m$, which approaches certainty as $m$ grows. The Bonferroni correction tests each at $\alpha / m$, and the Benjamini-Hochberg procedure controls the false discovery rate instead, both essential when scanning many series, many lags, or many anomaly thresholds at once.
Four named tests recur. The Augmented Dickey-Fuller (ADF) test has a unit-root (non-stationary) null, so a small $p$-value argues for stationarity, while the KPSS test inverts the roles with a stationarity null; running both is the standard stationarity diagnostic of Chapter 3. The Ljung-Box test has a white-noise null and checks whether residual autocorrelations are jointly zero, the model-adequacy check after fitting an ARIMA in Chapter 5. The Granger causality test is an $F$-test asking whether past values of one series improve the forecast of another, the predictive-precedence tool of Chapter 6. None of these proves a structural truth; each reports whether the data are compatible with a null, and each is read alongside plots and domain knowledge, never alone.
The multivariate Gaussian is the most important distribution in the book because it is the one distribution closed under every linear operation a filter performs. A $d$-dimensional Gaussian vector $\mathbf{x} \sim \mathcal{N}(\boldsymbol{\mu}, \boldsymbol{\Sigma})$ has mean vector $\boldsymbol{\mu} \in \mathbb{R}^d$, symmetric positive-definite covariance $\boldsymbol{\Sigma} \in \mathbb{R}^{d \times d}$, and density
Two closure properties make it the engine of the Kalman filter. First, an affine map of a Gaussian is Gaussian: if $\mathbf{y} = \mathbf{A}\mathbf{x} + \mathbf{b}$ then $\mathbf{y} \sim \mathcal{N}(\mathbf{A}\boldsymbol{\mu} + \mathbf{b},\, \mathbf{A}\boldsymbol{\Sigma}\mathbf{A}^{\top})$, which is precisely the predict step propagating the state and its covariance through the linear dynamics. Second, the conditional of a jointly Gaussian pair is Gaussian, and that is the update step. Partition a joint Gaussian as
and the distribution of $\mathbf{x}_1$ given an observed $\mathbf{x}_2$ is the Gaussian
Read this formula slowly, because it is the heart of two chapters at once. The conditional mean shifts the prior mean $\boldsymbol{\mu}_1$ by a correction proportional to the surprise $(\mathbf{x}_2 - \boldsymbol{\mu}_2)$, and the matrix $\boldsymbol{\Sigma}_{12}\boldsymbol{\Sigma}_{22}^{-1}$ that scales the correction is exactly the Kalman gain when $\mathbf{x}_1$ is the hidden state and $\mathbf{x}_2$ is the measurement. The conditional covariance shrinks the prior covariance by an amount the data explain, the variance reduction the update earns. The very same formula, with $\mathbf{x}_2$ a vector of training outputs, is the predictive equation of a Gaussian process. The Kalman filter of Chapter 7 is this conditioning identity, applied once per time step.
The snippet applies the conditioning formula directly to a scalar-observation tracking problem: a two-dimensional hidden state (position and velocity) is observed only through its position with measurement noise, and conditioning collapses the joint Gaussian onto the observation to give the updated belief. The result matches what a Kalman update would return, making the abstract identity concrete.
The probability reviewed here is not a museum piece; it is the active substrate of current temporal AI. Modern probabilistic forecasters such as DeepAR and the Gaussian-likelihood heads of foundation models like Chronos and Moirai output the parameters of these very distributions per time step, then train by the negative log-likelihood of Section 3. Conformal prediction reframes the hypothesis-testing machinery of Section 4 into distribution-free coverage guarantees, and diffusion-based generative time-series models lean on the Gaussian conditioning of Section 5 at every denoising step. Mastering these five ideas is the prerequisite for reading the uncertainty quantification of Chapter 19 and the generative models of Part IV as the small, principled extensions they are.
With the probabilistic toolkit in hand, the next appendix turns from describing uncertainty to minimizing loss. Appendix C: Optimization and Deep Learning Basics reviews gradient descent and its stochastic and adaptive variants, backpropagation, and the building blocks of neural networks, the machinery that turns the likelihoods and objectives defined here into trained temporal models. The log-likelihoods of Section 3 are the objectives Appendix C optimizes, so the two appendices are two halves of one story: what to optimize, and how.
3. Estimation, Maximum Likelihood, and a Word on Priors
import numpy as np
from scipy.optimize import minimize
from scipy.stats import norm
rng = np.random.default_rng(0)
y = rng.normal(loc=3.0, scale=2.0, size=500) # true mu=3, sigma=2
mu_hat, var_hat = y.mean(), y.var() # closed-form Gaussian MLE
print(f"closed form: mu={mu_hat:.3f} sigma={np.sqrt(var_hat):.3f}")
def neg_log_lik(theta): # theta = (mu, log_sigma)
mu, log_sigma = theta
return -norm.logpdf(y, mu, np.exp(log_sigma)).sum()
opt = minimize(neg_log_lik, x0=[0.0, 0.0]) # maximize log-lik = minimize its negative
mu_opt, sigma_opt = opt.x[0], np.exp(opt.x[1])
print(f"optimized: mu={mu_opt:.3f} sigma={sigma_opt:.3f}")4. Hypothesis Testing Essentials and the Book's Named Tests
5. The Multivariate Gaussian and Its Conditioning Formula
import numpy as np
mu = np.array([0.0, 1.0]) # prior mean: position 0, velocity 1
Sigma = np.array([[4.0, 1.0], # joint prior covariance over (pos, vel)
[1.0, 2.0]])
H = np.array([[1.0, 0.0]]) # we observe position only
R = np.array([[0.5]]) # measurement-noise variance
z = np.array([2.3]) # the noisy position reading
S = H @ Sigma @ H.T + R # innovation covariance (Sigma_22 here)
K = Sigma @ H.T @ np.linalg.inv(S) # Kalman gain = Sigma_12 Sigma_22^{-1}
mu_post = mu + K @ (z - H @ mu) # conditional mean
Sigma_post = Sigma - K @ H @ Sigma # conditional covariance
print("posterior mean:", np.round(mu_post, 3))
print("posterior cov:\n", np.round(Sigma_post, 3))What's Next?