A — Formula Cheat Sheet

Every formula in the book on one page, grouped by chapter. Print it (print icon) and use it for revision. Make sure you can explain each line, not just recite it.

Ch 2 — Generalization

Data model\(y = f(x) + \varepsilon,\ \ \mathbb{E}[\varepsilon]=0,\ \operatorname{Var}(\varepsilon)=\sigma^2\)
MSE\(\frac1n\sum_i (h(x_i) - y_i)^2\)
Normal equations\(X^\top X w = X^\top y\)
Line fit\(w_1 = \frac{\sum(x_i-\bar x)(y_i-\bar y)}{\sum (x_i-\bar x)^2},\ \ w_0 = \bar y - w_1\bar x\)
Bias–variance\(\mathbb{E}[(y-\hat g)^2] = (\bar g - f)^2 + \mathbb{E}[(\hat g - \bar g)^2] + \sigma^2\), with \(\bar g = \mathbb{E}_{\mathcal D}[\hat g_{\mathcal D}]\)
Ridge\(\min \lVert Xw-y\rVert^2 + \lambda\lVert w\rVert^2 \Rightarrow (X^\top X + \lambda I)w = X^\top y\)
Lasso\(\min \lVert Xw-y\rVert^2 + \lambda\sum|w_j|\) (sparse)
k-fold CV\(\text{CV} = \frac1k\sum_{i=1}^k \text{Err}_{\text{fold } i}\)

Complexity ↑ ⇒ bias ↓, variance ↑. More data ⇒ variance ↓. Underfit: both errors high and close. Overfit: low train, high test.

Restarts needed\(\mathbb{E}[\text{runs}] = 1/p\)
SA acceptance (maximize)\(P(\text{accept}) = e^{\Delta E/T}\) for \(\Delta E < 0\). (Minimizing cost: \(e^{-\Delta C/T}\).)
Geometric cooling\(T_{t+1} = \alpha T_t\)
Roulette selection\(p_i = f_i/\sum_j f_j\), expected copies \(N p_i\)
Bit mutation rate\(p_m \approx 1/L\)
8-queens\(h\) = attacking pairs. GA fitness = non-attacking pairs, max \(\binom82 = 28\)

Failure modes: local maxima, plateaus/shoulders, ridges. Mutation explores (restores lost alleles). Crossover exploits (combines building blocks). Too much selection pressure ⇒ premature convergence.

Ch 4 — Probability and utility

Conditional\(P(a|b) = P(a,b)/P(b)\)
Product / chain rule\(P(a,b)=P(a|b)P(b)\), \(P(x_1..x_n) = \prod_i P(x_i|x_1..x_{i-1})\)
Marginalization\(P(Y) = \sum_z P(Y, z)\)
Inference recipe\(\mathbf P(X|e) = \alpha\sum_y \mathbf P(X,e,y)\)
Bayes' rule\(P(h|e) = \dfrac{P(e|h)P(h)}{\sum_{h'}P(e|h')P(h')}\)
Odds formposterior odds = \(\frac{P(e|h)}{P(e|\neg h)}\) × prior odds
Independence\(P(a,b)=P(a)P(b)\). Conditional: \(P(a,b|c) = P(a|c)P(b|c)\)
Naive Bayes\(P(C|x) = \alpha P(C)\prod_i P(x_i|C)\). Laplace: \(\frac{n_{v}+1}{n + |V|}\)
Expectation\(\mathbb E[X]=\sum x P(x)\), \(\operatorname{Var}X = \mathbb E[X^2]-\mathbb E[X]^2\)
Lottery EU\(U([p_1,S_1;\dots]) = \sum_i p_i U(S_i)\)
MEU\(a^* = \arg\max_a \sum_{s'}P(s'|a)U(s')\)
Certainty equivalent\(U(CE) = \mathbb{EU}(L)\), risk premium = EMV − CE
Affine invariance\(U' = aU + b,\ a>0\) gives the same decisions

Axioms: orderability, transitivity, continuity, substitutability, monotonicity, decomposability. Concave U = risk-averse, linear = neutral, convex = seeking.

Ch 5 — Decision theory and MDPs

VPI\(\text{VPI}(E) = \sum_e P(e)\max_a \mathbb{EU}(a|e) - \max_a \mathbb{EU}(a)\ \ (\ge 0)\)
Discounted return\(\sum_t \gamma^t R(s_t) \le R_{\max}/(1-\gamma)\)
Bellman (optimality)\(U(s) = R(s) + \gamma\max_a\sum_{s'}P(s'|s,a)U(s')\)
Bellman (transition reward)\(U(s) = \max_a\sum_{s'}P(s'|s,a)[R(s,a,s')+\gamma U(s')]\)
Q-value\(Q(s,a) = R(s)+\gamma\sum_{s'}P(s'|s,a)U(s')\), \(\pi^*(s) = \arg\max_a Q(s,a)\)
Policy evaluation\(U^\pi = R + \gamma P^\pi U^\pi \Rightarrow (I-\gamma P^\pi)U^\pi = R\)
Contraction\(\lVert BU - BU'\rVert_\infty \le \gamma\lVert U-U'\rVert_\infty\). Stop when \(\delta < \varepsilon(1-\gamma)/\gamma\)
Primal LP\(\min \sum_s \alpha_s V(s)\) s.t. \(V(s) \ge r(s,a) + \gamma\sum_{s'}P(s'|s,a)V(s')\)
Dual LP\(\max \sum x(s,a)r(s,a)\) s.t. \(\sum_a x(s',a) - \gamma\sum_{s,a}P(s'|s,a)x(s,a) = \alpha(s')\), \(x\ge0\)
Belief update\(b'(s') = \alpha\, P(o|s')\sum_s P(s'|s,a)b(s)\)

Ch 6 — Decision trees

Entropy\(H(S) = -\sum_k p_k\log_2 p_k\). Binary: \(B(p) = -p\log_2p-(1-p)\log_2(1-p)\)
Information gain\(\text{Gain}(S,A) = H(S) - \sum_v \frac{|S_v|}{|S|}H(S_v)\)
Split info / gain ratio\(\text{SI} = -\sum_v\frac{|S_v|}{|S|}\log_2\frac{|S_v|}{|S|}\), GR = Gain/SI
Gini\(1 - \sum_k p_k^2\)
χ² pruning\(\Delta = \sum_k \frac{(p_k-\hat p_k)^2}{\hat p_k} + \frac{(n_k-\hat n_k)^2}{\hat n_k}\), \(\hat p_k = p\frac{p_k+n_k}{p+n}\)
Hypothesis count\(2^{2^n}\) Boolean functions of \(n\) attributes

Handy values: B(1/2)=1, B(1/3)=0.918, B(1/4)=0.811, B(2/5)=0.971, B(1/5)=0.722, B(1/7)=0.592, B(3/7)=0.985, B(5/14)=0.940.

Ch 7 — Bayesian networks

Factorization\(P(x_1..x_n) = \prod_i P(x_i|\text{parents}(X_i))\)
CPT sizeBoolean node with \(k\) Boolean parents needs \(2^k\) numbers
Noisy-OR\(P(\neg e|\text{causes}) = \prod_{i\ \text{true}} q_i\)
Markov blanketparents + children + children's other parents
Enumeration\(\mathbf P(X|e) = \alpha\sum_{y}\prod_i P(x_i|\text{pa}_i)\)
Likelihood weight\(w = \prod_{E_i} P(e_i|\text{parents}(E_i))\)
Gibbs step\(P(x_i|\text{mb}) \propto P(x_i|\text{pa}_i)\prod_{\text{children } Y}P(y|\text{pa}_Y)\)
CPT learning (MLE)\(\hat P(x|u) = \#(x,u)/\#(u)\)

Chain A→B→C and fork A←B→C: blocked if B observed. Collider A→B←C: blocked unless B or a descendant is observed (explaining away).

Classic numbers to recognize

  • PlayTennis: H(S) = 0.940. Gains: Outlook 0.247, Humidity 0.152, Wind 0.048, Temp 0.029.
  • 4×3 world (\(R=-0.04, \gamma=1\)): start cell \(U = 0.705\). Next to +1: 0.918.
  • Burglary: P(B | j, m) = 0.284. P(B | j, m, e) = 0.003 (explaining away). P(j,m,a,¬b,¬e) = 0.000628.
  • Disease test (1%, 90%, 9%): P(D|+) ≈ 0.092.
  • Sprinkler: P(R | s, w) = 0.320.