Chapter 0. The mathematics this book uses

Data Mining as Observation, draft 0.3, 2026-09-09. Read this chapter once before chapter 1, after primers L and S if a first linear algebra or statistics course is far behind you, and return to it whenever a later chapter cites a section by number. Nothing here is a result. Each section introduces one tool, gives a small example a reader can check by hand, and says where the book uses it.

This book assumes what TSK assumes [1]. Comfort with vectors and matrices at the level of a first linear algebra course, and probability at the level of a first statistics course. Every tool beyond that is introduced here before it is used. A reader who has taken those two courses and reads this chapter can read the rest of the book.

Two primers stand before this chapter for the reader whose first courses are far behind. Primer L rebuilds the linear algebra from a list of numbers to the singular value decomposition, and primer S rebuilds probability and statistics from counting to the bootstrap and the null model, each idea with an example that can be checked by hand. Each section below that stands on a primer section names it in a line marked Builds on, and the tables in sections L.10 and S.12 run the map the other way, from each primer section to the chapter 0 section built on it.

The first six sections build one object. Rows are vectors, a consumer's sensitivity to a row is a vector, the average of that vector's outer product over the rows is a matrix, the read operator of section 0.5, and the directions that matrix sends to zero are the ones the quotient of section 0.6 declares the same. Every later chapter's claim that a consumer reads some directions and not others is a statement about that one object, and the tools are introduced in the order needed to define it.

0.1 Rows as vectors

Builds on. Primer L sections L.1 and L.2.

A row of a table with d numeric columns is a vector in d dimensions. Write it as x, with coordinates x1 through xd. Two rows x and y have a dot product, the sum of the products of matching coordinates. The length of a vector, also called its norm, is the square root of its dot product with itself.

The dot product measures agreement in direction. For two vectors of length one it equals the cosine of the angle between them. For vectors of any length, cosine similarity is the dot product divided by the product of the two lengths. It equals one when the vectors point the same way, zero when they are perpendicular, and negative one when they point opposite ways. Two vectors with dot product zero are called orthogonal.

$$x\cdot y=\sum_{i=1}^{d}x_i y_i,\qquad \|x\|=\sqrt{x\cdot x},\qquad \cos\theta=\frac{x\cdot y}{\|x\|\,\|y\|}. \tag{0.1}$$

That the cosine lies between minus one and one, that it is unchanged by scaling a vector while the dot product scales with it, and that the square of the dot product is at most the product of the squared lengths, are machine-checked in Lean in appendix C.

Example. x = (3, 4) has length 5. y = (4, 3) has length 5. Their dot product is 12 + 12 = 24. Cosine similarity is 24 over 25, or 0.96. Scaling y to (8, 6) doubles its length and leaves the cosine at 0.96, because cosine ignores length.

Used in. Chapter 3 throughout. Chapter 11, where the choice between cosine and dot product decides whether a compressor is safe.

0.2 Matrices, projections, and subspaces

Builds on. Primer L sections L.3, L.4, and L.5.

A matrix is a table of numbers that turns one vector into another by multiplication. A d by d matrix A sends x to Ax. The matrices in this book are almost all symmetric, meaning the entry in row i and column j equals the entry in row j and column i.

A projection onto a direction u of length one sends x to the multiple of u that is closest to x. That multiple is the dot product of x with u, times u. The number itself, the dot product with u, is the coordinate of x along u.

$$\operatorname{proj}_u(x)=(u\cdot x)\,u,\qquad \|u\|=1. \tag{0.2}$$

That projecting twice is projecting once, that the remainder is orthogonal to the direction, and that anything orthogonal to the direction leaves the projection unchanged, are machine-checked in Lean in appendix C.

A subspace is a set of directions closed under addition and scaling. The set of all vectors along u is a one-dimensional subspace. The set of all vectors in a plane through the origin is a two-dimensional subspace. The rank of a matrix is the dimension of the subspace its outputs fill. A rank-one matrix sends every input to a multiple of one fixed direction.

Example. Let u = (0.6, 0.8), which has length one. Projecting x = (3, 4) onto u gives coordinate 1.8 + 3.2 = 5, so the projection is 5u = (3, 4). Projecting x = (4, 3) onto u gives 2.4 + 2.4 = 4.8, so the projection is (2.88, 3.84).

That the rank of a matrix is at most its row and column counts, that an outer product has rank at most one, that a product has rank at most either factor's, and that a sum of orthogonal vectors obeys Pythagoras, are machine-checked in Lean in appendix C.

Used in. Section 0.5, where a read operator is a weighted sum of projections. Chapters 3, 4, and 11.

0.3 Variance in many dimensions

Builds on. Primer L section L.6 and primer S sections S.2 and S.5.

For one column, the variance is the average squared distance from the mean. For d columns, the covariance matrix is the d by d table whose diagonal entries are each column's variance and whose off-diagonal entries measure how two columns move together. It is symmetric. Write it as $\Sigma$.

The trace of a square matrix is the sum of its diagonal entries. The trace of a covariance matrix is the total variance across all columns. Two datasets can have the same total variance and distribute it across columns completely differently.

$$\Sigma_{ij}=\mathbb E\big[(x_i-\mu_i)(x_j-\mu_j)\big],\qquad \operatorname{tr}\Sigma=\sum_{i}\Sigma_{ii}. \tag{0.3}$$

That the trace is linear, that the trace of an outer product is the vector's squared length, and that the trace of a product does not depend on the order, are machine-checked in Lean in appendix C.

That the quadratic form of the covariance along a direction is the variance of the projection onto it, equation 0.4, that its trace is the total variance, and that it is positive semidefinite, are machine-checked in Lean in appendix C.

Example. A dataset with variance 0.3 in the first coordinate and 1.7 in the second, and no covariance between them, has covariance matrix with diagonal (0.3, 1.7) and trace 2.0. A dataset with the diagonal reversed, (1.7, 0.3), also has trace 2.0. Chapter 3 shows a reader that ranks these two 4.1 to one.

The variance along a direction $u$ of length one is $u^{\top}\Sigma u$, the dot product of $u$ with $\Sigma u$. It is the variance of the coordinates along u. For the first dataset and u = (1, 0) it is 0.3. For u at 15 degrees from the first axis, u = (0.966, 0.259), it is 0.966 squared times 0.3 plus 0.259 squared times 1.7, which is 0.280 + 0.114 = 0.394.

$$\operatorname{Var}(u\cdot x)=u^{\top}\Sigma\,u. \tag{0.4}$$

Same total variance, different variance along one directioncovariance diag(0.3, 1.7)covariance diag(1.7, 0.3)reader u at 15 degreesdiag(0.3, 1.7)diag(1.7, 0.3)00.511.52variance along udiag(0.3, 1.7) 0.3940.394firstdiag(1.7, 0.3) 1.6061.606secondtrace is 2.0 for both
Figure 0.1. Two covariances with the same trace, 2.0, and a reader at 15 degrees. The variance the reader sees is 0.394 along the first and 1.606 along the second.

That the variance is the mean square less the squared mean, that it is zero only for a constant column, and that the covariance and the read operator are positive semidefinite with nonnegative diagonals, are machine-checked in Lean in appendix C.

Used in. Chapter 3 section 3.2 and chapter 4 throughout. Whenever the book writes the trace of one matrix times another, it means a weighted total variance, with the weights given by the first matrix.

0.4 Eigenvalues, eigenvectors, and the spectrum

Builds on. Primer L sections L.7 and L.8.

A symmetric d by d matrix has d special directions, its eigenvectors, along which it acts as pure scaling. Along eigenvector v with eigenvalue lambda, the matrix sends v to lambda v. The eigenvectors of a symmetric matrix can be chosen orthogonal to each other, and the eigenvalues of a covariance matrix are never negative. The list of eigenvalues is called the spectrum.

$$\Sigma\,v_i=\lambda_i v_i,\qquad \Sigma=\sum_{i=1}^{d}\lambda_i\,v_i v_i^{\top},\qquad v_i\cdot v_j=0\ (i\ne j). \tag{0.5}$$

That eigenvectors of a symmetric matrix with distinct eigenvalues are orthogonal, and that every eigenvalue of a positive semidefinite matrix is nonnegative, are machine-checked in Lean in appendix C.

For a covariance matrix, the eigenvector with the largest eigenvalue is the direction of largest variance, and the eigenvalue is that variance. That is principal component analysis. TSK Appendix B derives it [1]. The book uses the vocabulary as follows.

Isotropic means every direction has the same variance. All eigenvalues are equal. Anisotropic means they differ. A spectrum is concentrated when a few eigenvalues carry most of the total.

Whitening rescales the data so that its covariance becomes the identity matrix. It divides each eigenvector direction by the square root of its eigenvalue. After whitening every direction has variance one, and distances no longer favour the high-variance directions.

$$x_{\mathrm w}=\Sigma^{-1/2}(x-\mu),\qquad \Sigma^{-1/2}=\sum_i\lambda_i^{-1/2}\,v_i v_i^{\top}. \tag{0.6}$$

That each whitened coordinate has unit variance, and that the squared length of a whitened row is the Mahalanobis form of equation 0.33, are machine-checked in Lean in appendix C in the eigenbasis.

Effective rank answers the question of how many directions a matrix really uses, without choosing a cutoff. It is the square of the sum of the eigenvalues divided by the sum of the squared eigenvalues. It equals one when a single eigenvalue carries everything and equals d when all eigenvalues are equal.

$$r_{\mathrm{eff}}=\frac{\big(\sum_i\lambda_i\big)^{2}}{\sum_i\lambda_i^{2}}. \tag{0.7}$$

That a spectrum with a fraction of its mass in one direction has effective rank at most one over that fraction squared is machine-checked in Lean in appendix C.

That the effective rank lies between one and the number of eigenvalues, with the flat spectrum and the single eigenvalue at the two ends, is machine-checked in Lean in appendix C.

Example. Eigenvalues (4, 1, 0, 0). Sum is 5, sum of squares is 17, effective rank is 25 over 17, or 1.47. The matrix mostly uses one direction and partly a second. Eigenvalues (1, 1, 1, 1) give effective rank 16 over 4, or 4.

Used in. Chapter 3 section 3.3, where the eigenvectors of a graph's Laplacian give the spectral embedding. Chapter 4 sections 4.2 and 4.5. Chapter 11 section 11.7.

0.5 Reading a vector, and the read operator

Builds on. Primer L sections L.4 and L.9.

A consumer is any computation that takes a vector in and gives a number out. A classifier's score for one class. A ranking function's score for one candidate. A regression's prediction. Call the number C(x).

The sensitivity of the consumer at x is the vector of partial derivatives of C with respect to each coordinate. It is also called the gradient and written g. It points in the direction in which a small change to x moves the output most. A coordinate the consumer never uses has a zero entry in g.

Sensitivity can be measured without knowing the formula for C. Change coordinate i of x by a small amount h, evaluate C again, and divide the change in output by h. That is a finite difference, and doing it once per coordinate costs d evaluations of C. Doing it in both directions, plus and minus h, costs 2d and is more accurate. Chapter 11 section 11.7 says why 2d is the price at one operating point for a probe confined to the directions it chooses, and that whether many cheaper points can average their way back to the population operator was measured within a budget range, not proved.

$$g_j\;\approx\;\frac{C(x+h\,e_j)-C(x-h\,e_j)}{2h},\qquad j=1,\dots,d. \tag{0.8}$$

That the central difference recovers the derivative of a quadratic exactly at every step, while the one-sided difference is off by the curvature times the step, is machine-checked in Lean in appendix C.

The read operator of a consumer summarizes its sensitivity over a whole dataset. For each row, form the $d$ by $d$ matrix whose entry in row $i$ and column $j$ is $g_i g_j$. This is the outer product of $g$ with itself. Average those matrices over the rows. The result, written $P_C$, is symmetric, its eigenvectors are the directions the consumer is most sensitive to on average, and its eigenvalues say how sensitive. Directions the consumer never reads have eigenvalue zero. The eigenvectors with nonzero eigenvalue span the read subspace. $P_C$ is an average of local, linearized sensitivities. Each local operator is positive semidefinite, so squared sensitivities cannot cancel in the average, and the kernel of the average is the intersection of the local kernels over the rows, up to sets of rows of measure zero. A direction with eigenvalue zero in $\bar P_{C,\mu}$ is therefore locally unread at almost every row of the workload, for a nonlinear consumer as much as for a linear one. What the average does not give is a global statement about pairs of inputs, and section 0.6 says what that costs. Chapter 2 section 2.2 keeps the pointwise operator, equation 0.11 evaluated at one row, apart from this average, and the book says which it means wherever the difference matters. The average is also taken over a particular set of rows, a dataset or a workload, and depends on which. Where that matters the book writes $\bar P_{C,\mu}$ with $\mu$ the distribution the rows were drawn from, and a read operator measured on one footprint is a claim about that footprint.

$$P_C=\mathbb E\!\left[g\,g^{\top}\right],\qquad g=\nabla C(x). \tag{0.9}$$

The book's central quantity is the trace of $P_C$ times $M_\delta$, where $M_\delta$ is the second-moment matrix of an error, the average over rows of the error's outer product with itself. The identity below is exact, with no centering, for a fixed read operator, which is the linear case. For a nonlinear consumer whose error depends on the row, the first-order distortion is the average over rows of $\delta(x)^{\top}P_C(x)\delta(x)$, and the trace of the averaged operator times the averaged second moment is a factorized surrogate of it, exact when the operator and the error's outer product are uncorrelated across rows and otherwise an approximation, which the book uses because it is what the instruments of chapter 11 can measure. When the error has mean zero, $M_\delta$ is also the error's covariance, written $\Sigma_\delta$, and the book writes $\Sigma_\delta$ only where an error is centered by construction. A reconstruction error is not centered merely to remove its bias, since the consumer feels the bias too, and a reader who wants the covariance form must add the mean's own term, $\mu_\delta^{\top}P_C\mu_\delta$. The trace of $M_\delta$ is the mean squared vector norm of the error, which is $d$ times the per-coordinate mean squared error a report usually quotes. By section 0.3, that is the total variance of the error weighted by how much the consumer reads each direction. It is the error as the consumer experiences it, to first order and in the factorized form the next paragraph qualifies. Setting P_C to the identity matrix weights every direction equally and recovers plain total squared error. The book calls that the identity reader.

$$d_O=\operatorname{tr}(P_C\,M_\delta)=\mathbb E\!\left[\delta^{\top}P_C\,\delta\right],\qquad M_\delta=\mathbb E\!\left[\delta\delta^{\top}\right],\qquad P_C=I\ \Rightarrow\ d_O=\operatorname{tr}M_\delta. \tag{0.10}$$

The identity in equation 0.10, and its identity-reader case, are machine-checked in Lean in appendix C.

Example. A consumer that reads only the first coordinate has $g=(1,0)$ everywhere, $P_C$ is the matrix with a single one in the top-left corner, and $\operatorname{tr}(P_C\Sigma)$ is the variance of the first coordinate alone. A consumer that reads the 15-degree direction of section 0.3 has $P_C$ equal to the outer product of $(0.966, 0.259)$ with itself, and $\operatorname{tr}(P_C\Sigma)$ is the 0.394 computed there.

When the consumer outputs a vector rather than a number, the gradient becomes a matrix of partial derivatives called the Jacobian, and the read operator is the average of the Jacobian transposed times the Jacobian. The book mentions the Jacobian by name only in chapter 2. Everything else uses the scalar case. The $G$ in equation 0.11 is the local metric on the consumer's output, a positive semidefinite matrix that says how a small change in the output is scored, and it exists only when the observer's output metric has a local quadratic representation at that output. A dataset-level loss, accuracy, F1, precision, a rank correlation, or dollars lost, is not such a matrix and cannot be inserted into the formula. For an observer scored by such a loss the read operator is computed on the score the loss is applied to, with $G$ the identity, which is the scalar case of equation 0.9, and the loss enters through the decision the score feeds.

$$P_C(x)=J(x)^{\top}G\big(C(x)\big)\,J(x),\qquad J(x)=\frac{\partial C}{\partial x}(x),\qquad \bar P_{C,\mu}=\mathbb E_{\mu}\!\left[P_C(x)\right]. \tag{0.11}$$

Used in. Everywhere. The definition is repeated in chapter 2 with more care. That the average is positive semidefinite, that its diagonal is the mean squared sensitivity to each coordinate, and that its kernel is the intersection of the rows' kernels are machine-checked in Lean in appendix C.

0.6 Quotients, or deciding what not to see

Builds on. Primer L section L.4 and primer S section S.5.

Take a set of objects and a rule for when two of them count as the same. The rule groups the set into classes. The quotient is the set of classes. A quotient throws away exactly the differences the rule declares irrelevant.

$$x\sim_C x'\quad\Longleftrightarrow\quad d_G\big(C(x),C(x')\big)=0. \tag{0.12a}$$

$$x\sim_{\bar P_{C,\mu}} x'\quad\Longleftrightarrow\quad x-x'\in\ker\bar P_{C,\mu}. \tag{0.12b}$$

Equation 0.12a is exact consumer equivalence: the outputs at $x$ and $x'$ coincide under the output metric, with $d_G$ the distance that metric induces. Equation 0.12b is equality in the workload-averaged read operator, two inputs differing only in directions the operator does not read. The two coincide for an affine consumer with a fixed output geometry, where the Jacobian and the metric are constant and the kernel of $\bar P_{C,\mu}$ is exactly the set of directions the output cannot move. For a nonlinear consumer they part company, and section 0.6 and the cosine example below show how: the averaged kernel can be trivial while the consumer still identifies whole rays. That an affine consumer is constant along every direction its gradient does not read, and that the squared-length consumer has a full-rank averaged operator although each row reads one direction, are machine-checked in Lean in appendix C.

Example. Take all nonzero vectors and declare two the same when one is a positive multiple of the other. Each class is a direction, and the quotient is the set of directions, which is the unit sphere. The angle between two directions is a distance on this quotient, and cosine similarity is the similarity score that reports it, since the angle is the arccosine of the cosine. It cannot see length because length is what the rule discarded.

Every similarity measure in chapter 3 induces a distance on some quotient, and the book keeps the two words apart. A similarity is a score that grows with nearness, and its distance is the one it induces, the angle for cosine, one minus the correlation for correlation, one minus the Jaccard coefficient for Jaccard, each on the quotient that discards what the measure ignores. That the Jaccard coefficient lies in the unit interval and is zero exactly when the sets are disjoint is machine-checked in Lean in appendix C. Correlation distance lives on the quotient that discards shift and scale, and Jaccard distance on the quotient that discards joint absence. When the book says a consumer induces a quotient, it means the consumer's read operator declares two inputs the same when they differ only in directions of eigenvalue zero. That equivalence is exact for an affine consumer with a fixed output geometry, and it names one of three things the book keeps apart. Exact equivalence is that the consumer's outputs at $x$ and $x'$ are the same under its output metric. A local null direction is one in the kernel of $P_C(x)$ at a row, unread there. A workload-common null direction is one in the kernel of $\bar P_{C,\mu}$, unread at almost every row of the workload, since the kernel of the average is the intersection of the local kernels. For a nonlinear consumer the third does not deliver the first. Cosine similarity is the case to hold in mind. At every row it ignores the radial direction, so each local operator has a kernel, but the radial direction turns with the row, the average of those operators can have no kernel at all, and cosine still identifies every ray. The quotient the instruments of chapter 11 measure is the workload-common one.

That the correlation is the cosine of the centred columns, so that it lies between minus one and one and is unchanged by a shift or a positive rescaling, is machine-checked in Lean in appendix C.

Used in. Chapter 3 section 3.1, chapter 11 section 11.1.

0.7 Bits, budgets, and where to spend them

Builds on. Primer S section S.10.

Storing a number to more precision costs more bits. For a uniform quantizer at high rate, where the rounding error is spread evenly across a step, each extra bit halves the rounding error, so the squared error falls by a factor of four per bit. Coarse quantizers, codebooks with unequal steps, and errors that are not spread evenly depart from that rule, and chapter 4 reports where a measured allocation departed from the formula that rests on it. A compressor with a budget of B bits per row must decide how many bits each of d directions gets.

Take the directions to be the eigenvectors of the data's covariance, with variances $v_i$, and let $s_i=u_i^{\top}P_C u_i$ be the consumer's sensitivity along the $i$th of them, so that both numbers are read in one basis. The consumer's error from rounding direction $i$ with $b_i$ bits is about $s_i v_i$ times four to the power of $-b_i$. The total error is the sum over directions, because the directions are uncorrelated and their errors add. Minimizing the total subject to the bits summing to $B$ has a closed form. Direction $i$ gets half the base-two logarithm of $s_i v_i$ divided by a constant, or zero bits if that would be negative. The constant is set so the bits add up to $B$.

$$D(b)=\sum_i s_i v_i\,4^{-b_i},\qquad b_i=\max\!\Big(0,\ \tfrac12\log_2\frac{s_i v_i}{\theta}\Big),\qquad \sum_i b_i=B. \tag{0.13}$$

That a direction above the water, given these bits, contributes exactly the water level, and the two-direction case of the allocation's optimality, are machine-checked in Lean in appendix C.

Water-filling, three directions, budget 3 bitsdirectionsensitivity times variance, log scale0.10.5124816direction 1, weight 8, bits 22 bitsw = 8direction 2, weight 2, bits 11 bitw = 2direction 3, weight 0.1, bits 00 bitsw = 0.1water level 0.5bits per directionhalf of log2 of w over 0.5clipped at zero
Figure 0.2. Water-filling three directions with sensitivity-weighted variances 8, 2, and 0.1 at a budget of 3 bits. The water level is 0.5. The third direction sits under the water and receives no bits.

This is called water-filling, because if you draw each direction's $s_i v_i$ as a column and pour a fixed amount of water over the diagram, the water level is the constant, and the columns below the surface get no bits. The name comes from the same calculation for radio channels, where the columns are signal power. Here the columns are sensitivity times variance, and that is the whole difference between compressing for reconstruction and compressing for a consumer.

Example. Three directions with $s_i v_i$ equal to 8, 2, and 0.1 and a budget of 3 bits. Water-filling gives about 2 bits to the first, 1 to the second, and 0 to the third, which sits under the water. Uniform allocation would give 1 each and waste a bit on the direction the consumer barely reads.

That one more bit doubles the levels, halves the step, and quarters the high-rate squared error, and that bits add across directions, are machine-checked in Lean in appendix C.

That the bit and nat conversions undo each other and that one nat is between 1.4426 and 1.4427 bits is machine-checked in Lean in appendix C.

Used in. Chapter 4 section 4.2, chapter 11 section 11.5.

0.8 Comparing rankings, and scoring a classifier

Builds on. Primer S sections S.5 and S.9.

Many consumers produce rankings rather than numbers. Two rankings of the same items can be compared without caring about the scores that produced them.

Spearman correlation replaces each item's score with its rank, then computes the ordinary correlation between the two rank lists. It is one when the rankings agree exactly and negative one when they are reversed.

$$\rho_S=1-\frac{6\sum_i d_i^{2}}{n(n^{2}-1)},\qquad d_i=\text{difference of the two ranks of item } i. \tag{0.14}$$

That the correlation is at most one, one for identical rankings, and minus one for three items in opposite orders, and that ranks are unchanged by a strictly increasing transform of the score, are machine-checked in Lean in appendix C.

Kendall correlation looks at every pair of items and asks whether the two rankings order the pair the same way. It is the fraction of agreeing pairs minus the fraction of disagreeing pairs. It is also one for perfect agreement and negative one for reversal, and it is easier to bound from below, which is why chapter 11's certificate uses it.

$$\tau=\frac{\#\{\text{concordant pairs}\}-\#\{\text{discordant pairs}\}}{n(n-1)/2}. \tag{0.15}$$

That the correlation lies between minus one and one and is unchanged by a strictly increasing transform of either score is machine-checked in Lean in appendix C.

Example. Five items ranked (1, 2, 3, 4, 5) by one method and (1, 3, 2, 4, 5) by another. Of the ten pairs, one pair, items 2 and 3, is ordered differently. Kendall is nine tenths minus one tenth, or 0.8. Spearman is 0.9.

AUROC, the area under the receiver operating characteristic curve, scores a classifier that outputs a number per item when the truth is one of two classes. It equals the probability that a randomly chosen positive item scores higher than a randomly chosen negative one. A random scorer gets 0.5. A perfect one gets 1.0. It does not depend on where a threshold is placed.

$$\mathrm{AUROC}=\Pr\big[s^{+}>s^{-}\big]\ +\ \tfrac12\Pr\big[s^{+}=s^{-}\big]. \tag{0.16}$$

That the AUROC lies in the unit interval, is one at perfect separation and zero at perfect reversal, is one half for a constant score, and is unchanged by a strictly monotone transform of the score, is machine-checked in Lean in appendix C.

Example. Positives score (0.9, 0.7, 0.4). Negatives score (0.6, 0.3). Of the six positive-negative pairs, the positive scores higher in five. AUROC is five sixths, or 0.83.

Every rank statistic has a chance level, the value a random ranking would achieve on average. For correlations it is zero. For AUROC it is 0.5. For the overlap between a recovered subspace and a true one it is the ratio of the subspace dimension to the ambient dimension, and chapter 11 prints that ratio beside every reading.

That a constant score has AUROC one half, reliability weight zero, and Kendall correlation zero with any other score is machine-checked in Lean in appendix C.

Used in. Chapter 8 sections 8.5 and 8.6, chapter 11 sections 11.3 and 11.8, chapter 3 section 3.3.

0.9 Uncertainty, nulls, and multiple comparisons

Builds on. Primer S sections S.3, S.4, S.6, S.7, S.8, and S.11.

A number computed from a sample would come out differently on a different sample. The book reports that variation in four ways, and the reader should recognize each.

A confidence interval is a range that would contain the true value in a stated fraction of repeated samples, usually 95 percent. When the book writes a number followed by an interval, the interval is the range and the number is the sample estimate.

A bootstrap estimates that interval by resampling the data with replacement many times and recomputing the number each time. A paired bootstrap resamples the same rows for two methods at once, so that the interval is on their difference and the sampling variation they share cancels out. That the variance of a difference is the sum of the variances minus twice the covariance, so that pairing narrows the interval exactly when the two scores covary positively, is machine-checked in Lean in appendix C.

A standard error is the spread of the estimate across repeated samples. A difference of z standard errors is reported as z sigma. A p-value is the probability of seeing a difference at least that large if the true difference were zero. Small p means the sample would be surprising under no effect. The book uses these words as reported by the source, and never as evidence on their own.

A null model is a version of the data with the structure under test removed and everything else kept. The right comparison for a measured statistic is the same statistic on the null, not zero. Chapter 8 section 8.4 has three cases where the null was more than half the apparent effect.

Example. Suppose 1000 queries each retrieve 10 neighbours from 100000 points, so 10000 slots are handed out and the average point gets 0.1. If slots were handed out at random, the count for one point would follow a Poisson distribution with mean 0.1, under which a count of 4 or more has probability about 4 in a million. Among 100000 points, about 0.4 of them would reach 4 by chance, so the no-structure ceiling is 3 and a point with count 30 is ten times the ceiling. Chapter 3 section 3.5 uses exactly this null.

$$\Pr[X\ge c]=1-\sum_{i<c}e^{-\mu}\frac{\mu^{i}}{i!},\qquad c^{\star}=\max\{c:\ n\Pr[X\ge c]\ge 1\},\qquad \mu=\frac{n_q\,k}{n}. \tag{0.17}$$

That the standard error halves only when the independent draws quadruple, never rises with more draws, and tends to zero, is machine-checked in Lean in appendix C. That a p-value against a null sample is at most uniform under the null, and that the chance that at least one of several intervals misses is at most their number times the miss rate, are machine-checked in Lean in appendix C.

That the counts over the corpus sum to the slots handed out, so that their mean is this $\mu$, and that the tail never increases with the count, so that the ceiling is a threshold, are machine-checked in Lean in appendix C.

Multiple comparisons. Test forty hypotheses at a five percent threshold and two will pass by chance. Reporting the best of forty as if it were the only test overstates it forty-fold. TSK chapter 10 covers the standard corrections. Chapter 8 section 8.5 adds the case of repeated cross-validation, where the folds are not independent and a standard test counts each one as if it were [4]. That the best of many tests is at least any single one, and the numbers, are machine-checked in Lean in appendix C.

$$\widehat{\operatorname{Var}}_{\mathrm{NB}}=\Big(\frac1J+\frac{n_{\mathrm{test}}}{n_{\mathrm{train}}}\Big)\hat\sigma^{2},\qquad \frac{\widehat{\operatorname{Var}}_{\mathrm{NB}}}{\hat\sigma^{2}/J}=1+J\,\frac{n_{\mathrm{test}}}{n_{\mathrm{train}}}. \tag{0.18}$$

That the correction never shrinks the variance, that the inflation grows without bound in the fold count, and the chapter 8 numbers, 251, 15.84, and 3.98, are machine-checked in Lean in appendix C.

Used in. Chapter 8 throughout. Chapter 3 section 3.5.

0.10 Graphs and their spectra

Builds on. Primer L section L.7.

A graph is a set of nodes and a set of edges joining pairs of them. The degree of a node is the number of edges it has. A neighbourhood graph on a dataset joins each row to its k nearest rows, or to every row within a radius. The geodesic distance between two nodes is the length of the shortest path along edges. On a neighbourhood graph built from points on a curved surface, geodesic distance follows the surface rather than cutting through the space around it.

A manifold is a curved surface of some dimension, like a sphere or a torus, that looks flat when viewed closely. A dataset lies on a manifold when its rows, though given in many coordinates, really vary along only a few. The number of directions it varies along is the intrinsic dimension. A sheet rolled into a spiral in three dimensions has intrinsic dimension two.

The Laplacian of a graph is a matrix built from its edges. In the normalized form the book uses, its entry for a pair of joined nodes is negative one over the square root of the product of their degrees, its diagonal is one, and everything else is zero. Its eigenvectors, ordered by eigenvalue from smallest up, are the smoothest functions on the graph. The first is the square root of the degree at each node, which is the constant vector carried through the normalization, and for the unnormalized Laplacian, the degree matrix less the adjacency, the first is the constant vector itself. The next few vary slowly from one region of the graph to another. Using a node's values in the first few nontrivial eigenvectors as its coordinates is the spectral embedding, and clustering those coordinates is spectral clustering, which TSK covers in chapter 7 [1, 6].

$$L=I-D^{-1/2}AD^{-1/2},\qquad D=\operatorname{diag}(d_1,\dots,d_n),\qquad L\,u_k=\lambda_k u_k,\ \ 0=\lambda_1\le\lambda_2\le\cdots. \tag{0.19}$$

That the Laplacian's quadratic form is half the weighted sum of squared differences across edges, nonnegative, zero on every constant, and positive on any function that differs across an edge, is machine-checked in Lean in appendix C for the unnormalized form.

Two facts about that embedding matter for chapter 3. First, as a neighbourhood graph on a manifold grows, its low eigenvectors converge to the smoothest functions on the manifold itself, so the embedding becomes a picture of the manifold. Second, a particular scaling of the embedding, dividing each eigenvector by the square root of its eigenvalue, makes the squared Euclidean distance in the embedding equal the resistance, which is the commute time, the expected number of steps a random walk needs to go from one node to the other and back, divided by the volume of the graph. Chapter 3 section 3.3 is about what happens to that distance on large graphs.

$$\Psi_i=\left(\frac{u_k(i)}{\sqrt{\lambda_k\,d_i}}\right)_{k\ge2},\qquad \|\Psi_i-\Psi_j\|^{2}=R(i,j)=\frac{C(i,j)}{\operatorname{vol}(G)}. \tag{0.20}$$

That the commute time is symmetric, that the resistance is its scaling by the volume, and that the collapsed resistance of chapter 3 depends on two nodes only through their degrees, are machine-checked in Lean in appendix C.

A map between two spaces is bi-Lipschitz when it neither stretches nor shrinks any distance by more than a fixed factor. If a map is bi-Lipschitz with factor 2, every pair of points ends up between half and twice as far apart as it started. Chapter 3 uses the word for embeddings that preserve geodesic distance up to such a factor. The weaker property that the ordering of distances is preserved, without any bound on the stretch, is called rank-faithful.

$$\frac1K\,d(x,y)\ \le\ d'\big(f(x),f(y)\big)\ \le\ K\,d(x,y)\qquad\text{for all }x,y. \tag{0.21}$$

That the factor is at least one, that factors multiply under composition, that a nearest neighbour is preserved when the runner-up is more than the factor squared times as far, and that a bi-Lipschitz map can still reverse the order of two distances, so that rank-faithful is a separate word, are machine-checked in Lean in appendix C.

Example. A path graph on nodes 1 through 5, each joined to its neighbours. Degrees are 1, 2, 2, 2, 1. The geodesic distance from node 1 to node 5 is 4. The second eigenvector of the Laplacian, once each node's value is divided by the square root of its degree, rises monotonically from one end to the other, so plotting nodes by that one coordinate recovers the line. Without the degree correction the two end nodes, which have degree 1 where the others have degree 2, sit slightly out of order. That correction is the row normalization chapter 3 is about, seen for the first time.

Path graph, second eigenvector, node by node-0.4-0.200.20.412345678910nodeeigenvector valueas computedas computed, 1 0.333as computed, 2 0.443as computed, 3 0.361as computed, 4 0.236as computed, 5 0.082as computed, 6 -0.082as computed, 7 -0.236as computed, 8 -0.361as computed, 9 -0.443as computed, 10 -0.333degree correcteddegree corrected, 1 0.333degree corrected, 2 0.313degree corrected, 3 0.255degree corrected, 4 0.167degree corrected, 5 0.058degree corrected, 6 -0.058degree corrected, 7 -0.167degree corrected, 8 -0.255degree corrected, 9 -0.313degree corrected, 10 -0.333as computeddegree correctedvalues as computed in the toolkit check of 2026-09-03
Figure 0.3. The second eigenvector of a ten-node path graph's normalized Laplacian, as computed and after dividing each node's value by the square root of its degree. Only the corrected one is in order at the two ends.

That the degrees of a graph sum to twice its edge count, and that no node has degree more than the number of other nodes, are machine-checked in Lean in appendix C.

That a neighbourhood graph gives every node exactly k out-neighbours, and that its mutual form is symmetric, a subgraph, and gives no node more than k mutual neighbours, are machine-checked in Lean in appendix C.

Used in. Chapter 3 section 3.3, chapter 9.

0.11 The language-model vocabulary the examples use

Builds on. Primer S section S.10.

Several of the book's measurements were made on language models, because they are the largest consumers of vectors in current practice. The reader does not need to know how those models work. The following words are enough.

A token is a piece of text, roughly a word. A language model reads a sequence of tokens and outputs a probability for the next one. Perplexity is a score for that output on a test text, equal to two to the power of the average number of bits the model needs per token. Lower is better. A perplexity of 12 means the model is about as uncertain as a fair choice among 12 tokens. A perplexity of 10000 means the model has been broken.

$$\mathrm{PPL}=2^{H},\qquad H=-\frac1T\sum_{t=1}^{T}\log_2 p\big(w_t\mid w_{<t}\big). \tag{0.22}$$

That perplexity is at least one, equals the vocabulary size for a uniform model, and is monotone in the bits, and the chapter 11 numbers as bits per token, are machine-checked in Lean in appendix C.

Inside the model, attention is the operation that lets each token look at earlier ones. Each token produces three vectors, a query, a key, and a value. The query is compared to every earlier key by dot product, the dot products are turned into weights by the softmax function, which exponentiates them and divides by their sum so they are positive and add to one, and the weights are used to average the values. A head is one such operation. A model has many, and each has its own queries, keys, and values. The KV cache is the stored keys and values of earlier tokens, kept so they need not be recomputed. Compressing it is the subject of several examples, and the keys are the case where compression goes wrong, because the softmax reads the dot product with the query, which depends on each key's coordinates at their own scale. That the cache's size is linear in the tokens, that a compression preserving every query-key score preserves every head output, and that two keys of the same direction and different lengths have different scores, so that cosine is not the score, are machine-checked in Lean in appendix C.

$$\operatorname{softmax}(z)_i=\frac{e^{z_i}}{\sum_j e^{z_j}},\qquad \text{output}=\sum_i\operatorname{softmax}\!\Big(\frac{q\cdot k_i}{\sqrt{d}}\Big)_{\!i}\,v_i. \tag{0.23}$$

That a rotary position embedding preserves length and makes the score of a query against a key depend on their relative position alone is machine-checked in Lean in appendix C for the plane rotation it is built from.

That the softmax weights are positive and sum to one, are unchanged by a common shift of the scores, and preserve the scores' order, and that the head reads the keys only through their scores against the query, so that a key change the query does not read leaves the output unchanged, are machine-checked in Lean in appendix C.

The rotary position embedding is a rotation applied to queries and keys that encodes where each token sits in the sequence. The book mentions it only to say that the keys were measured after it was applied. Teacher forcing means feeding the model the correct text as context rather than its own earlier outputs. It removes the model's own mistakes from the context and is used in chapter 11 to test whether a failure compounds. That the free run agrees with the reference for as long as the forced predictions are right, and parts from it at the first error, is machine-checked in Lean in appendix C.

Quantization replaces each number with one of a small set of allowed values, called a codebook, so that it can be stored in a few bits. A per-channel quantizer chooses a scale per coordinate. A direction-only quantizer stores each vector's length exactly and rounds its direction. Product quantization splits a vector into pieces and quantizes each piece with its own codebook. An inverted file index partitions the vectors into cells by k-means, which TSK covers in chapter 7, and answers a query by searching only the cells whose centres are nearest to it. The number of cells searched is the probe count, and recall at k is the fraction of a query's true k nearest neighbours that the index returned.

KL divergence measures how far one probability distribution is from another, in units called nats when natural logarithms are used. Zero means identical. The book quotes it once, in chapter 4, as a distortion between two attention outputs. ROUGE is a family of scores for generated text against a reference. The book quotes one variant, ROUGE-L, in chapter 8, as the metric a retracted result was measured in. That ROUGE-1 recall lies in the unit interval and is one for any rearrangement of the reference, since it reads bags and not order, is machine-checked in Lean in appendix C.

$$\mathrm{KL}(p\,\|\,q)=\sum_i p_i\ln\frac{p_i}{q_i}\ \ge 0. \tag{0.24}$$

The inequality, that the divergence of a distribution from itself is zero, and that the two directions can differ, are machine-checked in Lean in appendix C.

Used in. Chapter 4 section 4.2, chapter 8 section 8.9, chapter 11 sections 11.2 and 11.9.

0.12 Hashes, commits, and seals

Chapter 8 and the sources tables use three words about records, hash, commit hash, and sealed, and the glossary defines them. Their definitions, the worked examples, and what a hash does and does not prove are in appendix D, which is read when chapter 8 is, and not in week one.

0.13 Time, staleness, and the cost of a bit

Chapter 13 adds a clock and needs six more words, coherence time, certificate, witness, refresh floor, false-clear rate, and coverage, with the cache and radio vocabulary beside them. Their definitions, equations 0.24 to 0.27, and the worked examples are in appendix D, read with chapter 13.

0.14 Classifier vocabulary

Builds on. Primer S sections S.1 and S.9.

Chapter 6 uses five words beyond TSK's.

A classifier produces a score per row, and a threshold turns the score into a decision. Rows above the threshold are called positive. The margin of a row is how far its score sits from the threshold, and the decision boundary is the set of inputs whose score equals the threshold. A linear classifier's boundary is a flat surface perpendicular to its weight vector, and its score moves only along that vector.

F1 combines precision, the fraction of predicted positives that are truly positive, and recall, the fraction of true positives that were predicted, as twice their product over their sum. It depends on the threshold. Sweeping the threshold over every distinct score and taking the best F1 gives the optimal thresholded F1 of a score, which is a property of the score's ranking alone.

$$P=\frac{TP}{TP+FP},\qquad R=\frac{TP}{TP+FN},\qquad F_1=\frac{2PR}{P+R}. \tag{0.28}$$

That precision and recall lie in the unit interval, that F1 lies between the smaller of the two and their arithmetic mean, and the counts form of F1, are machine-checked in Lean in appendix C.

Example. Thirty true positives, ten false positives, twenty false negatives. Precision is 0.75, recall is 0.6, and F1 is 2 times 0.45 over 1.35, or 0.667.

Calibration asks whether a score of 0.8 means the row is positive eighty percent of the time. Expected calibration error is the average, over bins of the score, of the difference between the bin's mean score and its fraction of positives.

$$\mathrm{ECE}=\sum_b\frac{n_b}{n}\,\big|\bar s_b-\bar y_b\big|. \tag{0.29}$$

That the error lies in the unit interval and is zero exactly when every weighted bin is calibrated is machine-checked in Lean in appendix C.

A formula classifier is a score written as a short expression in the features, such as the smaller of two features plus a third, with a threshold. Chapter 6 asks when such a formula suffices and when only an ensemble of trees will do.

Used in. Chapter 6, chapter 8 section 8.5.

0.15 Clustering vocabulary

Chapter 9 uses four more words beyond TSK chapter 7.

A validity index scores a clustering without labels. The sum of squared errors adds each row's squared distance to its cluster centre. The silhouette of a row is the difference between its mean distance to the nearest other cluster and its mean distance to its own cluster, divided by the larger of the two. It runs from negative one to one, and the mean silhouette over rows scores the clustering.

$$\mathrm{SSE}=\sum_{k}\sum_{i\in\mathcal C_k}\|x_i-c_k\|^{2},\qquad s_i=\frac{b_i-a_i}{\max(a_i,b_i)}. \tag{0.30}$$

That the silhouette lies between minus one and one, is positive exactly when the row is closer to its own cluster, and is unchanged by a common rescaling of the distances, is machine-checked in Lean in appendix C.

Example. Points at 0, 1, 5, and 6 on a line, clustered as the first two against the last two. The point at 0 has mean distance 1 to its own cluster and 5.5 to the other, silhouette 4.5 over 5.5, or 0.818. The point at 1 has 1 and 4.5, silhouette 0.778. By symmetry the mean silhouette is 0.798. The sum of squared errors is 1.0.

A multiplet is a group of eigenvalues that are equal or nearly so. Symmetric shapes produce them. The circle's Laplacian has every eigenvalue twice, because a wave around the circle can be shifted. Section 0.10 introduced the Laplacian and its eigenvalues. That the cycle's eigenvalue formula gives the same value at $k$ and at $n - k$ is machine-checked in Lean in appendix C.

Weyl's law says how the number of eigenvalues below a value grows with that value [7]. On a shape of intrinsic dimension d it grows like the value to the power d over 2. On a circle, dimension one, the count grows like the square root. On a surface, dimension two, it grows linearly. Chapter 9 uses this to read a dataset's dimension from its spectrum before reading its shape.

$$N(\lambda)=\#\{k:\lambda_k\le\lambda\}\ \sim\ C_d\,\lambda^{d/2}. \tag{0.31}$$

A template match compares a measured list of numbers, such as the first eight eigenvalue ratios, to a stored list for each candidate shape, and picks the candidate with the smallest root-mean-square distance between the logarithms.

$$\operatorname{dist}(m,t)=\sqrt{\frac18\sum_{k=1}^{8}\big(\ln m_k-\ln t_k\big)^{2}}. \tag{0.32}$$

That this distance is symmetric, zero between a list and itself, and unchanged when both lists are scaled by the same factor, which is why the match reads shape and not size, is machine-checked in Lean in appendix C.

Used in. Chapter 9.

0.16 Outlier vocabulary

Builds on. Primer L sections L.3 and L.7 and primer S section S.4.

Chapter 10 uses five more words beyond TSK chapter 9.

The Mahalanobis distance of a row from the mean is its Euclidean distance after whitening, equation 0.6. It counts a deviation along a high-variance direction as small and the same deviation along a low-variance direction as large.

$$d_M(x)=\sqrt{(x-\mu)^{\top}\Sigma^{-1}(x-\mu)}. \tag{0.33}$$

That the distance is zero at the mean, unchanged when data and covariance are rescaled together, and equal to the squared Euclidean length after whitening, is machine-checked in Lean in appendix C.

Example. With mean zero and covariance diagonal (1, 4), the row (3, 4) has Euclidean distance 5 and Mahalanobis distance the square root of 9 over 1 plus 16 over 4, which is the square root of 13, or 3.61.

Balanced accuracy scores a classifier over several classes as the mean of the per-class recalls, so a large class cannot hide a small one.

$$\mathrm{BA}=\frac1K\sum_{k=1}^{K}\frac{\text{correct in class }k}{\text{rows in class }k}. \tag{0.34}$$

That balanced accuracy lies between the worst class and the best, and the example in which plain accuracy is 0.99 and balanced accuracy is 0.5, are machine-checked in Lean in appendix C.

The Robin Hood index of a set of counts is the fraction of the total that would have to move from the points above the mean to the points below it to make every count equal. Zero means perfectly even, and values near one mean a few points hold nearly everything.

$$\mathrm{RH}=\sum_i\max\!\Big(0,\ \frac{N_i}{\sum_j N_j}-\frac1n\Big). \tag{0.35}$$

That the excess above the mean is half the total absolute deviation, that the index is zero exactly at equality and at most one, and that a common scaling of the counts leaves it unchanged, are machine-checked in Lean in appendix C.

Example. Counts 10, 6, 2, 2, and 0 over five points sum to 20, so the shares are 0.5, 0.3, 0.1, 0.1, and 0 against an even share of 0.2. The excess above 0.2 is 0.3 plus 0.1, so the index is 0.4.

Min-over-strata is the rule that a verdict over several groups is the worst group's verdict, not the average. A gate at 0.9 on groups scoring 0.94, 0.88, and 0.71 fails at 0.71, although the mean is 0.84.

Abstention is the verdict a group receives when it has too few rows or too few queries to score. An abstention is counted and reported, and it is neither a pass nor a fail.

Used in. Chapter 10.

0.17 Text vocabulary

Chapter 12 uses five more words beyond the week's papers.

A bag of words turns a document into a vector with one coordinate per vocabulary term, holding the count of that term. Word order is discarded. TF-IDF rescales each count by how rare the term is across the collection, so that a term appearing in every document carries no weight.

$$w_{t,d}=\mathrm{tf}_{t,d}\cdot\ln\frac{N}{\mathrm{df}_t},\qquad \mathrm{tf}_{t,d}=\frac{\text{count of }t\text{ in }d}{\text{length of }d},\qquad \mathrm{df}_t=\text{documents containing }t. \tag{0.36}$$

That a term in every document carries no weight, that the weight falls as the term spreads, and that a bag of words is unchanged by rearranging the document, are machine-checked in Lean in appendix C.

Example. A term appears 3 times in a 100-word document and in 10 of 1000 documents. Its weight is 0.03 times the natural log of 100, or 0.138. A term appearing 5 times in the same document but in 500 documents has weight 0.05 times the log of 2, or 0.035.

Latent semantic analysis applies the singular value decomposition of section 0.4 to the TF-IDF matrix and keeps the top components, which is principal components on documents. A contrastive objective trains an encoder by pulling pairs declared similar together and pushing others apart, and the pairs are where the encoder learns what similar means. A challenge set is a test collection built so that a shortcut which passes the benchmark fails on it.

A retrieval-augmented pipeline answers a question by splitting documents into chunks, embedding each chunk as a vector, indexing the vectors, retrieving the chunks nearest the embedded question, and handing them to a generator. Each stage reads the output of the one before it.

Used in. Chapter 12.

0.18 Deployment vocabulary

Chapter 14 uses five more words beyond TSK chapter 10.

An attribution assigns each feature a share of one prediction. Importances, partial dependence, and Shapley-style attributions are the common forms [8]. A gradient-based attribution estimates the consumer's sensitivity of section 0.5 at a point or averaged over points, and the read operator of equation 0.9 is what it estimates. Permutation importance, partial dependence, and Shapley values answer related but different questions, and chapter 14 section 14.5 says which.

A disparate impact ratio compares the rate of a favourable decision between two groups. Equalized odds asks that the true-positive rate and the false-positive rate be the same across groups. A known result is that when the groups' base rates differ, a classifier cannot be calibrated within each group and also have equal error rates across groups, except in the trivial cases [9, 10]. The three demands are three output metrics, and no single one serves all three.

$$\mathrm{DI}=\frac{\Pr[\hat y=1\mid g=a]}{\Pr[\hat y=1\mid g=b]},\qquad \text{equalized odds}:\ \mathrm{TPR}_a=\mathrm{TPR}_b,\ \mathrm{FPR}_a=\mathrm{FPR}_b. \tag{0.37}$$

That the ratio is one exactly at parity, that the four-fifths rule is a statement about the difference between the two rates, and that equalized odds and parity of outcomes conflict whenever the base rates differ, are machine-checked in Lean in appendix C.

A reliability weight turns a validated encoder's held-out AUROC into an authority between zero and one, so that a consumer counts each score in proportion to what its encoder has earned. Chance earns zero and a perfect encoder earns one. The weight is a discrimination weight, since twice AUROC minus one measures how well the encoder separates the classes and says nothing about whether its scores are calibrated. The calibration evidence is the expected calibration error of equation 0.29 reported beside it, and the book keeps the source's name, reliability weight, for the pair.

$$w=\max\big(0,\ 2\cdot\mathrm{AUROC}-1\big). \tag{0.38}$$

That the weight lies in the unit interval, is zero at chance level, and is unchanged by any strictly monotone recalibration of the score, so that it is a discrimination weight, is machine-checked in Lean in appendix C.

Example. AUROC 0.63 gives weight 0.26. AUROC 0.853 gives 0.706.

A paraphrase class is a set of rewordings of one input that preserve its meaning. A decision is invariant to re-description when it does not move across the class, and the ratio of movement within a class to movement between unrelated inputs measures how invariant it is.

Escalation is the decision to hand an item to a person rather than decide it, and it is chapter 10's abstention applied to a single decision.

Used in. Chapter 14.

Exercises

Exercises come in three tiers in every chapter. Warm-up questions are answered in a sentence or two. By-hand problems are computed on paper and checked against the answers at the end of the set. Programming problems produce a committed notebook or script.

Warm-up

  1. Explain why cosine similarity cannot distinguish the vectors (1, 1) and (5, 5), and name one consumer for which that is a defect.
  2. Write a two by two matrix of rank one and state the direction all of its outputs lie along.
  3. Two datasets have covariance matrices with the same trace. Name one consumer that distinguishes them and one that does not.
  4. A read operator has effective rank 1. What does that say about the consumer? What does effective rank d say?
  5. Why does a paired bootstrap give a narrower interval on the difference between two methods than two separate bootstraps would?
  6. State the chance level of a Spearman correlation, of AUROC, and of the overlap between a recovered two-dimensional subspace and the true one in ten dimensions.
  7. What does a commit hash fix that a file's modification time does not?
  8. Explain in one sentence why water-filling gives some directions zero bits.

By hand

  1. Let x = (1, 2, 2) and y = (2, 2, 1). Compute both lengths, the dot product, and the cosine similarity.
  2. A covariance matrix has diagonal (2, 0.5) and no covariance between the coordinates. Compute the variance along u = (0.6, 0.8) and along v = (0.8, 0.6).
  3. A read operator has eigenvalues (9, 3, 3, 1). Compute its effective rank.
  4. A consumer computes $C(x)=3x_1-x_2$. Write its gradient, its read operator as a two by two matrix, and the trace of the read operator times Sigma for Sigma with diagonal (1, 4) and for Sigma with diagonal (4, 1).
  5. Four directions have sensitivity-weighted variances 16, 4, 1, and 0.25 and the budget is 4 bits. Compute the water-filling allocation. State which direction is starved.
  6. Two methods rank four items as (1, 2, 3, 4) and (2, 1, 4, 3). Compute the Kendall and Spearman correlations.
  7. Positives score (0.8, 0.5, 0.5) and negatives score (0.6, 0.5, 0.2). Compute AUROC, counting a tie as half.
  8. Five hundred queries each retrieve ten neighbours from a corpus of fifty thousand points. Compute the mean count per point, the no-structure ceiling under the Poisson null, and the hub excess of a point with count 12.
  9. One hundred repeated cross-validation folds are run with a test-to-train ratio of one to nine. Compute the Nadeau-Bengio variance inflation and the standard-error inflation.
  10. Write the normalized Laplacian of a path graph on four nodes.

Programming

  1. Implement the finite-difference read operator of section 0.5 for the consumer C(x) equal to tanh of the dot product of a fixed random w with x, in eight dimensions, spending 2d calls per operating point over fifty random points. Report the overlap between the top eigenvector of your estimate and the direction of w.
  2. Implement Kendall and Spearman correlation from scratch and verify them on exercise 14.
  3. Simulate exercise 16 by assigning five thousand retrieval slots to fifty thousand points at random, one hundred times. Report the distribution of the busiest count and compare it to the Poisson ceiling.
  4. Implement water-filling and verify exercise 13. Then double the budget and report which direction stops being starved.
  5. Build the path graph of exercise 18 with ten nodes, compute the eigenvectors of its normalized Laplacian, and plot the nodes by their value in the second eigenvector, once as computed and once after dividing each node's value by the square root of its degree. State which plot recovers the line in order and what happens at the two end nodes in the other.

Answers to the warm-up and by-hand problems are collected in the answer key at the end of the book.

Homework 0. The toolkit check

Assigned in week 1, due with Lab 1. Ten points.

Submit one notebook and one page of text.

Notebook (7 points). Programming exercises 19 through 23, each in its own cell, each producing the number or plot the exercise asks for. The notebook runs top to bottom on a fresh kernel.

Text (3 points). For each of the eighteen tool sections of this chapter, sections 0.1 to 0.18, one sentence naming a topic from the ECE 514 syllabus where that tool will appear, and why. A section you cannot place earns zero for that line, and a section placed wrongly earns zero, so guess carefully.

Grading rule. A notebook that does not run earns zero for the notebook. A number without the code that produced it earns zero for that exercise.

previous, Primer S. Probability and statistics from the first course  ยท  next, Chapter 1. What data mining is, and how it fails