Skip to main content
Advanced Statistical Methods

Dimensionality Reduction, Principal Component Analysis, and Linear Discriminant Analysis

Published: 2026-08-11
Level: postgraduate
Audience: Postgraduate students in Advanced Statistical Methods

Prerequisite Knowledge

This lecture builds on the following concepts from earlier lectures. If any feel unfamiliar, review the linked notes before proceeding.

Previously Covered in This Subject

  • Multicollinearity — covered in Lecture 8 (Multiple Linear Regression, Adjusted R², and Multicollinearity)
  • Simple and multiple linear regression — covered in Lecture 8 (Simple Linear Regression and the Decomposition of Variation)
  • Proportion of variation explained — covered in Lecture 8 (Coefficient of Determination)

13.1 Dimensionality Reduction

13.1.1 The Idea: Rows, Columns, and Many Attributes

Hook: How do you draw a picture of a dataset that has 10,000 columns? You cannot — which is why the whole field of dimensionality reduction exists.

Most real datasets are tables. The rows are observations; the columns are attributes, which you will also hear called features or input variables — the same thing under three names. One row holds one thing you measured (one person, one customer, one machine), and each column holds one measurement taken on it (age, income, engine temperature). A dataset with observations and attributes is an table: rows and columns.

With two attributes, say height and weight, you can plot the whole dataset on a flat scatter diagram and see everything at a glance. Draw a horizontal axis for height in centimetres and a vertical axis for weight in kilograms; every person becomes one dot, and the cloud of dots shows the whole dataset in one picture. With three attributes, a three-dimensional graph still works — you can spin it around and see the points from any angle. Beyond that, drawing the data stops being practical, and every extra attribute makes the analysis more complex. Four, five, or a hundred attributes cannot be drawn on a page, and each extra column adds to the computational cost of every method you run.

Real problems routinely come with thousands of columns. A single gene-expression study measures thousands of genes per sample; a colour image is millions of pixel values; a bank's credit file holds hundreds of indicators per customer. So the question this unit answers is practical: what do you do when your data has far more dimensions than you can visualize?

13.1.2 The Catch: Reduce the Dimension but Keep the Information

Dimensionality reduction means moving from a higher dimension to a lower one — from an -dimensional dataset down to three dimensions, or from three to two, or from two to one. The "dimension" here is the number of attributes: a two-dimensional dataset lives on a flat page, a three-dimensional one lives in space, and every added attribute adds a new axis of the same kind.

Cutting the dimension is only half the job. The moment you reduce, a second question appears: is there any information loss? If reducing from a high dimension to a low one throws away half of the information in the original data, the reduction is pointless. You would have a small dataset that no longer says what the big one said. The real goal is to come down in dimension while keeping the maximum available information intact. A reduction technique is useful only when it does both — fewer dimensions and no meaningful information loss.

Analogy: Think of a road map. The Earth's surface is three-dimensional, but a map is flat — two dimensions. The map drops the altitude, the curvature, and most of the detail, yet it keeps exactly the information a driver needs: the roads, the distances, the relative positions. That is dimensionality reduction done well: you choose the low-dimensional picture that preserves the structure that matters for your question. The map analogy breaks where PCA and the methods in this unit differ from a human mapmaker: a map is designed by someone who already knows what matters, while PCA has to discover the most informative direction from the data alone, with no human judgement in the loop.

Pitfall: Dropping whole columns at random is not dimensionality reduction — it is information destruction. Picking two variables out of fifty and deleting the other forty-eight throws away whatever the deleted columns contributed, including structure that no single column carries alone. Proper reduction (like the principal components of the next section) replaces many correlated columns with a few new ones that keep the information. Also remember the reverse trap: reducing to a low dimension never creates information that was not there — a good reduction keeps the signal that exists, it cannot invent more.

Real-world connection: this is not a classroom exercise. Genomics, image processing, finance, and marketing all routinely face datasets with thousands of columns; the ability to compress them to a handful of meaningful axes without losing the signal is what makes many machine learning pipelines feasible at all.

13.1.3 The Two Main Techniques

Two well-known data reduction techniques carry this material: principal component analysis (PCA) and Fisher's linear discriminant analysis (LDA).

The two main techniques: Principal component analysis (PCA) reduces dimensions by finding the directions of maximum variation in the data, then projecting the data onto the best of those directions. Linear discriminant analysis (LDA) reduces dimensions for classification by finding the direction that best separates the classes, so that projected points from different classes land far apart. PCA asks "where does the data spread the most?"; LDA asks "where do the groups differ the most?"

Both were worked through on a small two-dimensional example, chosen on purpose. With only two dimensions, the variation of the data and the classification behavior of each algorithm are visible with your own eyes — you can see the cloud of points, the direction it stretches along, and where the classes sit — which is exactly why the examples stay so small, and why the same reasoning extends to larger datasets later. The two-dimensional picture is a scaled-down version of the thousands-of-columns problem from 13.1.1: if you understand which direction to project in two dimensions, you already understand the whole method.

Recap: Dimensionality reduction takes data from many dimensions to few, and it earns its keep only when the reduction keeps the information. Two techniques will do the job for the rest of this unit: PCA, which follows the direction of maximum variation, and LDA, which follows the direction of maximum class separation. Next, 13.2 builds the first of them, principal component analysis, from the ground up.

13.2 Principal Component Analysis

13.2.1 What PCA Is

Hook: If a cloud of points stretches out along one particular direction, projecting the whole cloud onto that single direction loses the least information of any one-dimensional view. How do you find that direction without eyeballing it?

Principal component analysis is a dimensionality reduction technique discovered by Hotelling, a famous statistician, way back in 1933, and today it is used extensively in machine learning algorithms. Its age should not fool you: the idea is so fundamental that modern pipelines still run it as a standard first step.

The objective of PCA is to find the most accurate data representation in a lower dimensional space by projecting the data in the direction of maximum variation. "Projecting" means dropping perpendiculars from every point onto a chosen line (in two dimensions) or plane (in higher dimensions), and reading off where each perpendicular lands. The projection is "most accurate" when the chosen direction captures as much of the spread of the data as possible — the projected points stay far apart, so the view along that direction still distinguishes different observations. How do we identify that direction? By considering the highest eigenvalue.

To follow the reasoning properly you need some linear algebra — above all eigenvalues and eigenvectors — because the math of PCA runs on them. An eigenvector (a direction that a matrix only stretches, never turns), written , and its eigenvalue (how much that direction gets stretched), written , are the two objects the entire method is built on: each principal direction is an eigenvector, and its eigenvalue tells you how much variation that direction carries. That is why matrix courses are the standard prerequisite for this material. Real-world: PCA and LDA sit inside many current machine learning pipelines — from face recognition to finance and genomics — and the linear algebra underneath them is exactly why matrix courses are the standard prerequisite for understanding them.

13.2.2 Orthogonality: From Correlated x's to Uncorrelated z's

Start with original data on two variables, and . PCA transforms the data into new variables and , called the principal components. The key property is orthogonality: if and are highly correlated, then the transformed and are uncorrelated — no dependency remains between them. The old variables carry overlapping information; the new ones do not, which is what makes them clean building blocks.

The two objectives of PCA: First, reduce the dimension — replace original variables with fewer new ones. Second, make the new variables independent of one another, so that each carries a piece of information no other already has. So the objectives of PCA are really two ideas joined: reduce the dimension, and make the new variables independent of one another. If two new components were still correlated, you would have shrunk the table but kept the redundancy — the reduction would be cosmetic.

Concretely, in the two-dimensional case, and are linear combinations of and . Because PCA forces them uncorrelated, the variation of the data cleanly splits between them: whatever variation is not on the first axis sits on the second, with no double counting. Orthogonality, in other words, is what guarantees that the information kept by the reduction is not duplicated.

13.2.3 Why Uncorrelated Components Matter: Multicollinearity

The reason orthogonality matters comes from multiple regression. Suppose is a function of independent variables, , written out as

where is the intercept and is the coefficient of the input . Each coefficient says "if goes up by one unit, changes by , with everything else held fixed" — so the whole setup quietly assumes the inputs can be varied independently. The whole setup assumes the inputs are independent, but in practice some of them are highly correlated.

The multicollinearity failure mode: When two inputs are highly correlated, the data cannot tell them apart: it sees them moving together, so it cannot say how much of the effect on belongs to and how much to . The estimated coefficients become unstable — a tiny change in the data can swing the individual 's wildly, even though the overall fit looks fine — and the prediction of becomes unstable, because the data cannot tell the correlated variables apart. A common rule of thumb: if the correlation between two predictor variables exceeds roughly 0.7 in absolute value, multicollinearity is a potential problem worth addressing before trusting the individual coefficients.

A common stopgap is to inspect the data, pick out which variables are highly correlated, and drop the redundant ones — any input that adds nothing to predicting is not worth carrying, in computation time or in model terms. That works, but it is a judgement call and it throws information away wholesale. PCA offers a cleaner path: transform the data first. After the transform, the function becomes , and the predictive power of is much better than it was with the raw correlated 's — because the 's are uncorrelated by construction, the regression no longer has to guess which correlated variable caused what. The orthogonality objective is not decoration — it removes a real failure mode of regression.

13.2.4 Reading the Data: Correlation and Variation in Each Direction

Consider a two-dimensional dataset: measures on two variables, meaning rows and two columns. After drawing the scatter diagram, one fact stands out: as increases, also increases, so the two variables are related in some sense. To measure how strong that linear relationship is, we compute the correlation matrix between and :

where and are one, because each variable is perfectly correlated with itself, and and are the same number, because the correlation of with equals the correlation of with . The correlation coefficient always lies between minus one and plus one: close to +1 means a strong linear relationship; close to −1 means a strong relationship running the other way; near 0 means no linear relationship at all. Looking at this scatter diagram, the guess is that comes out slightly more than 0.8 — a strong, positive, roughly linear relation. The same table extends to variables: the correlation matrix then shows the pairwise correlations of all the variables.

Beyond the correlation matrix, we also look at how the data spreads. In this two-dimensional case there are two possible directions of variation: the variation along the direction and the variation along the direction. Looking at the scatter, both spreads are substantial and similar — neither beats the other by much, so you cannot ignore either direction, and the picture does not yet tell us where to project.

To quantify these spreads we use the covariance matrix:

its top-left position holds the variation of , its bottom-right position holds the variation of , and the off-diagonal positions hold the covariation between and . The two are related: the covariance divided by the two standard deviations gives the correlation , so covariance carries the same direction information but in the raw units of the data — which is why variables measured on wildly different scales produce covariance matrices dominated by the large-unit variable. Software returns this matrix directly; the concept behind each entry is what we just described.

13.2.5 Rotating the Axes: From x1, x2 to z1, z2

With only two dimensions, the most we can reduce is from two to one. Along the way, the two resulting variables must stay independent. The move, as described in the earlier discussion: instead of thinking in the and directions, rotate the axis anticlockwise by an angle , rotate the axis by the same angle , and call the new axes and . The angle is ours to choose. The rotation is a standard change of axes:

Let us read this equation carefully. Each new variable is a weighted sum of the old ones: and . The matrix multiplies a column vector of old coordinates on the right, so it is the standard anticlockwise rotation of the coordinate axes: a point's new coordinate along is its old coordinate projected onto the rotated axis. The minus sign on is what makes the two new axes perpendicular, no matter which we pick — and perpendicular axes are exactly the uncorrelated, non-redundant frame PCA wants. (If the minus sign sat in the other entry, the same matrix would rotate the points instead of the axes, and the first principal component would come out mirrored.)

Analogy: Rotating the axes is like tilting a camera before taking a photo of a long, thin object. Point the camera along the object's length and the photo fills the frame — the object's full size is captured. Point it across the object and the photo shows almost nothing but background. The rotation angle is the camera tilt we get to choose; PCA chooses the tilt that maximizes how much of the data's spread shows up in the picture. The analogy breaks in one way: a photographer tilts by eye, while PCA finds the best tilt by solving for the largest eigenvalue of the covariance matrix — no eyeballing involved.

After the rotation, the same scatter plot redrawn on the axes shows something the -axes could not: the variation along is far larger than the variation along . Two conclusions follow in one move. First, and are highly uncorrelated — the orthogonality objective is met. Second, alone is enough to carry the maximum variation, and with it the maximum information, of the original data; along there is so little variation that it can be ignored. The whole business of PCA is captured in that picture: one rotated axis that carries nearly everything, one that carries almost nothing.

13.2.6 The Recipe: Covariance Matrix, Characteristic Equation, Eigenvalues, Eigenvectors

The recipe for the principal directions — three steps, and each step feeds the next:

  1. Covariance matrix. Compute the table whose diagonal entries are the variation of each variable and whose off-diagonal entries are the covariation between pairs (13.2.4). This matrix summarizes every spread and every relationship in the data.
  2. Characteristic equation. Solve (13.3 works this fully). The solutions are the eigenvalues.
  3. Eigenvalues and eigenvectors. The eigenvector points along a principal direction, and its eigenvalue tells us how much variation that direction carries. The largest eigenvalue picks the first principal component; the next largest picks the second, perpendicular to the first.

The order of the steps is the logic of the method: the data's spread lives in the covariance matrix, the eigenvalues of that matrix rank the candidate directions by how much variation they carry, and the eigenvectors actually draw those directions. Notice what this gives us: one short recipe replaces the eyeballing that worked in two dimensions but is impossible with a thousand columns. The next section runs this recipe on a two-dimensional dataset, step by step.

13.3 Worked Example: PCA on a Two-Dimensional Dataset

13.3.1 The Given Covariance Matrix

Hook: A covariance matrix is handed to us with the numbers already inside. Can we read off, from those four numbers alone, where the data varies the most — and how much of the total variation one direction captures?

The example uses a simple two-dimensional dataset along and ; the scatter plot again shows a near-linear relationship. Instead of asking for the covariance matrix to be built from raw data, the matrix is given directly:

The top-left entry 1.15 is the variation (variance) of ; the bottom-right entry 29.54 is the variance of ; the two off-diagonal entries, both 5.76, are the covariance between and . The task: find where the data varies the most, using this matrix.

Two readings of the matrix are worth making before any calculation. First, the covariance is large compared with the variances, which means the two variables move together strongly — dividing the covariance 5.76 by the product of the two standard deviations, , gives a correlation of about 0.99, a very strong positive linear relationship consistent with the near-linear scatter. Second, varies about 25 times more than (29.54 against 1.15), so any single-axis view that ignores 's spread would throw most of the variation away. Real-world: software does the eigen arithmetic for you — a one-line R documentation example shows how to get the eigenvalues of such a matrix directly — but the steps below show what that one line is really doing.

13.3.2 The Characteristic Equation and Its Determinant

To find where the variation is largest, we solve the famous characteristic equation — the determinant of minus times the identity matrix equals zero:

Here is the covariance matrix, (lambda) is an eigenvalue, and is the 2 by 2 identity matrix:

We write rather than a plain because subtracting a bare number from a matrix is not defined — each diagonal position of has to lose its own . So a 2 by 2 matrix gives two solutions for , one per diagonal entry, and each solution needs its own position on the diagonal. Substituting the numbers:

Worked step — the determinant. For a 2 by 2 determinant with entries , reading across the rows, the value is . Applied here, with , , , :

That is the entire determinant: the product of the diagonal entries (each with its subtracted) minus the product of the off-diagonal entries, . Setting this equal to zero is the characteristic equation — the condition under which the matrix has no inverse, which is exactly when a nonzero vector exists that is only stretched by . Sense-check: the matrix is symmetric and the off-diagonal product is positive, so the equation is the difference of two positive numbers — exactly the shape that can produce two real, positive solutions.

13.3.3 The Quadratic Equation and the Quadratic Formula

Expanding the determinant — multiplying the two binomials, subtracting, and collecting terms — produces a simple quadratic equation:

Worked step — the full expansion, line by line:

Notice what the expansion did: the coefficient of is exactly , the sum of the diagonal entries of — a fact that will reappear as the total-variation check in 13.3.4. Sense-check: every term has been moved to one side, the highest power is with coefficient 1, and all coefficients are real, so the quadratic formula applies directly.

The roots of any quadratic equation come from the quadratic formula: minus , plus or minus the square root of squared minus , over :

Exam note: do not worry about redoing this arithmetic; the calculation is here only to show the path behind the concept. In the exam, answer only what the question requires, and address whichever part is relevant. The exam expects no full eigenvalue calculation — knowing that the characteristic equation, the quadratic, and the two eigenvalues follow this path is what matters.

13.3.4 The Two Eigenvalues

Solving the quadratic gives two eigenvalues:

Worked step — the quadratic formula with real numbers. Here , , :

So:

The lecture reports . Sense-check 1 (the trace): adding the two eigenvalues gives 30.66 + 0.03 = 30.69 — the same number as 1.15 + 29.54, the sum of the diagonal entries of the covariance matrix. That is not a coincidence: the sum of the eigenvalues of any square matrix equals the sum of its diagonal entries (the trace), and that sum is the total variation of the data, used in the next step. Sense-check 2 (the determinant): the product of the eigenvalues, , matches the determinant of , — the second general rule linking eigenvalues to their matrix. Sense-check 3: the eigenvalues are real and positive, as they must be for a covariance matrix.

For convenience, the smaller value can be truncated to 0.03.

13.3.5 Eigenvectors and the Principal Directions

Each eigenvalue comes with an eigenvector. The second famous equation solves for the eigenvector belonging to the eigenvalue :

where is the column vector . The equation says: when the matrix acts on this direction, the result is times the direction itself — the direction is only stretched, never turned. Take first and solve the system; the solution gives the line of the first principal component — the direction onto which the data is projected.

Worked step — the eigenvector of the largest eigenvalue. With , the matrix is:

The equation is two equations. The first row says , so . Setting gives — the direction itself can be any scalar multiple, because the eigenvector equation only fixes the ratio. To report a clean direction we normalize: divide by the length :

Sense-check (plug back in): and , both rows of the equation satisfied up to rounding. The mapping that comes out of the trigonometric formulas is:

As a sanity check, this pair is exactly the normalized eigenvector of the covariance matrix belonging to : plugging it back into satisfies the equation up to rounding.

Repeat with the small eigenvalue, about 0.03, and you get the second eigenvector, the direction. The full computation runs exactly as before, so it is worth seeing once:

Worked step — the second eigenvector and the second component. With , the matrix is:

The first row says , so . Setting gives ; normalizing by the length gives:

Sense-check (orthogonality): the two normalized eigenvectors should be perpendicular, and their dot product is — exactly zero. The axis is perpendicular to , which is the axis-rotation property from 13.2.5 showing up in the numbers: the two principal directions are uncorrelated by construction. Sense-check (plug back in): substituting into leaves residuals near zero, again up to the rounding of the matrix entries.

13.3.6 Variance Explained: The 99 Percent Story

Now we can say how much of the total variation each principal component explains. The proportion of the total variation carried by component is its eigenvalue divided by the sum of all eigenvalues:

The logic: the sum of the eigenvalues is the total variation (the trace check from 13.3.4), and each eigenvalue is the amount of variation its own component carries — so the ratio is the share of the total.

Worked step — the shares, with real numbers. With and :

The first principal component explains about 99.9 percent of the total variation — reported in the lecture as 99 percent, since 0.999 rounds to about 1. For the second component:

about one tenth of one percent — "0.000 something", as the discussion put it. The two shares add up to , the whole of the total variation, which is the closing check on the arithmetic. Sense-check: every share is a number between 0 and 1, and the shares sum to 1 — as proportions must.

This number justifies the reduction. Because carries almost all of the variation, we can retain and ignore for further analysis: the two-dimensional dataset collapses to one dimension with the information intact. Visually, draw a bar chart of the eigenvalues: the horizontal axis names the two components (PC1, PC2), the vertical axis is the eigenvalue. The first bar reaches 30.66 — nearly the full height of the chart — while the second bar is a sliver of 0.03 at the base. That picture is the whole story of the reduction: one towering bar, one sliver, so keep the tall one.

13.3.7 The Reduction Decision Rule

The same reasoning scales to dimensions. From original variables, build principal components . Keep adding components until their eigenvalues together explain about 90 percent of the total variation; the remaining components can be ignored in further calculations. In this worked example the first component alone cleared the bar with room to spare (99.9 percent), so the rule says: keep one, drop the rest.

Scope and a warning: the rule works only when one component dominates. If the shares came out comparable, say 40 percent and 60 percent across two components, no such conclusion is possible, and dropping either component is not safe — each one carries nearly half of the information, so a one-dimensional projection would lose about half of the total variation. The 90 percent threshold is a working guideline, not a law of nature: the right cutoff depends on the problem, on how much information loss the analysis can tolerate, and on what the reduced data will be used for. What never changes is the check itself — compute the shares, and only reduce when the kept components truly carry the information.

Recap: The worked example ran the full PCA recipe on real numbers: characteristic equation, determinant, quadratic, eigenvalues and , eigenvectors and , and the variance-explained shares and . The trace, determinant, plug-back, orthogonality, and sum-to-one checks all confirmed the arithmetic. Because one component dominates, the reduction to a single keeps the information — a conclusion that will stand in sharp contrast to the next topic, where a different goal entirely drives the choice of direction.

13.4 Linear Discriminant Analysis

13.4.1 Maximum Variation Is Not Always Useful for Classification

Hook: The widest direction of a dataset and the most useful direction for telling its groups apart are two different lines — and PCA looks along the first while LDA looks along the second.

LDA stands for linear discriminant analysis, and it is often called Fisher's linear discriminant. The central contrast sits right here: PCA hunts for the direction of maximum variation, while LDA hunts for the direction that separates classes. The simple numerical example made the point: the direction of maximum variation can be useless for classification. Data projected along the direction of greatest spread can still leave the classes overlapping — maximum variation and maximum separation are different goals.

Think of two groups of points, each shaped like a small cloud. The overall dataset may stretch along one long axis — the direction of maximum variation — but if both clouds happen to lie side by side along that axis, their projections onto it overlap completely and you cannot tell which cloud a point came from. Meanwhile a much shorter direction, one that points across the gap between the two clouds, separates them perfectly. That is the failure PCA can have as a classification tool, and the motivation for LDA: it maximizes the variation between the two classes and minimizes the variation within each class, which is the same between-versus-within logic that cluster analysis will reuse later.

The central warning: the direction of maximum variation can be useless for classification. High total spread says nothing about whether the spread separates the groups. Before reducing dimensions for a classification task, ask which direction keeps the groups apart — otherwise a projection can erase exactly the difference the model needs to see.

Dimension compared PCA (principal component analysis) LDA (linear discriminant analysis)
Goal Maximum variation Maximum class separation
Question answered Where does the data spread the most? Where do the groups differ the most?
Uses Compression, visualization, removing multicollinearity Classification, predicting group membership
Uses class labels? No (unsupervised) Yes (supervised)
Best direction if classes overlap along the wide axis The wide axis (unhelpful for classification) The across-the-gap axis (separates the classes)

Pick PCA when you need a compact, uncorrelated description of the data itself; pick LDA when the whole point is to tell the classes apart.

13.4.2 Between-Class and Within-Class Variation

Think of LDA's goal as a ratio: make the spread between the classes as large as possible while the spread inside each class stays as small as possible. When the between-class variation is large and the within-class variation is small, the classes sit far apart as compact clouds, and a straight line can separate them. Each class should be a tight cluster, and the two clusters should be far apart; the line that best separates them cuts through the empty space between the clusters.

The LDA model. LDA builds a linear combination of the predictor variables — one score per observation — written in the same shape as a regression line:

where is the discriminant score, are the predictor variables, is the constant term, and are the discriminant coefficients. The dependent variable here is categorical — group membership — and is coded like a dummy variable, for example 0 for one class and 1 for the other. The coefficients are chosen by the ratio rule above: the method estimates 's so that the ratio of the between-group variation to the within-group variation is as large as possible, which makes the groups differ as much as possible on the discriminant score. That ratio, between-group variation over within-group variation, is measured by an eigenvalue: a higher eigenvalue means better separation and is always desirable. New observations get their scores from the same line and are assigned to the class whose typical score they land nearest, with the cut-off usually taken as the midpoint of the two class averages.

In the small example used in the lecture, the numerical problem was shown to make the PCA-versus-LDA contrast visible; the detailed calculation of how that separating line is derived — the full mathematical walkthrough — was left for the next session, where the same two-dimensional dataset is worked from the data up.

Exam note: the LDA problem is kept simple, with no extensive math to calculate, no functions or derivatives involved, and nothing like a heavy computation is expected in the exam for calculation purposes. What is examinable is the concept: LDA separates classes, PCA spreads variance, and the two directions are not the same.

Recap + bridge: PCA found the single axis that carries the most variation; LDA finds the single axis that best separates the classes, using the between-versus-within ratio. The next topic, cluster analysis, is previewed on the same logic — separate the groups, tighten each group — before the lecture returns to the full LDA calculation.

13.5 Cluster Analysis

13.5.1 The Preview: Inter-Cluster and Intra-Cluster Distance

Hook: Nobody tells a clustering algorithm which group each customer belongs to — yet it still has to divide the customers into groups. What makes one grouping better than another?

Cluster analysis is a technique for combining observations into clusters, so that similar observations end up in similar groups. The questions it answers: how do we group the data, and what is the minimum number of clusters needed? Unlike PCA and LDA, cluster analysis starts with no labels at all: the algorithm looks at the raw positions of the observations and groups the ones that sit close together.

The logic mirrors LDA: maximize the inter-cluster distance, the separation between different clusters, and minimize the intra-cluster distance, the spread inside each cluster. The more separated the clusters are, the more easily you can see distinct groups at the higher dimensional level; the tighter each cluster is, the more meaningful the grouping — every member of a cluster really is like its neighbours, and every cluster really is different from the others.

Distance is the engine of clustering. Clusters are defined by closeness, and closeness is measured by distance between observations. For data measured on interval or ratio scales, the standard choice is the Euclidean distance between two observations A and B with coordinates on two variables:

the straight-line distance you already know from geometry. With variables the same formula sums squared differences under the square root. The rule of the method is simple: the shorter the distance between two observations, the more similar they are — so a good grouping puts short distances inside clusters and long distances between them.

Worked example — Euclidean distance with real numbers. Two people rate two breakfast properties, nutrition and ease of preparation, each on a 10-point scale (1 = very important, 10 = very unimportant). Person A chooses (nutrition 1, ease 2); person B chooses (5, 2). The distance between them is:

Now a third person C chooses (6, 2). Then and . So B and C are the most similar pair — smallest distance — and the algorithm would group B with C first. Sense-check: all three people rate ease identically, so the distances reduce to the nutrition differences 4, 5, and 1 — B and C differ least, exactly as the formula found.

A caution on scaling (and a preview of the next section's open question): the Euclidean distance is not scale invariant. If one variable is measured in kilograms and another in grams, the larger-unit variable dominates the squared differences and quietly decides the clusters. That is why it is advisable to standardize the data before cluster analysis when the variables are measured on widely different units — though standardization itself can shrink real differences on the variables that separate the groups best, so the choice needs care. The same scaling question, in fact, is the student question left open in 13.6.

The reference material for the course names a cluster analysis book as the source for this method — the technique is standard and well documented, and the preview here only marks the territory the following session will explore on its own dataset. Real-world connection: this is exactly how customer databases are segmented — a travel company, for instance, can group its past customers by age, travel preferences, and spending so that each segment receives its own targeted offer, which is a far more effective use of a marketing budget than sending every offer to everyone.

13.5.2 What Comes Next

Two items were planned for the following session: the full LDA worked problem on a two-dimensional dataset, including the mathematics of how the separating line is found, and the cluster analysis discussion with its own dataset. Both stay on two dimensions so the variation and the classification behavior remain visible — the same reason the PCA example stayed two-dimensional in 13.3.

Recap + bridge: cluster analysis groups similar observations by distance, following the same between-versus-within logic as LDA: maximize the inter-cluster distance, minimize the intra-cluster distance. The next session delivers the two promised walkthroughs — the LDA separating line and cluster analysis on its own dataset — and the theme continues to be the same: keep the groups far apart, keep each group tight.

13.6 Student Questions and Answers

13.6.1 Standardizing the Data Before PCA

Q: Do we need to standardize the data before running PCA?

A: No answer was given in the lecture — the discussion closed on this question, and the doubt stayed open for the following session. What was settled is the question itself: the data's measurement units affect what PCA sees, because the covariance matrix is built from the raw values.

For context, here is what the answer will have to weigh when the discussion resumes. Standardizing a variable means rescaling it so that it has mean 0 and variance 1: subtract the variable's mean and divide by its standard deviation, written . Every variable then contributes on the same footing, and PCA is run on the correlation matrix of the data rather than the raw covariance matrix.

The tension is the same one flagged for cluster analysis in 13.5.1. A variable measured in large units — say income in thousands — will dominate the covariance matrix, and the first principal component will be dragged toward it, not because it carries more information but simply because its numbers are bigger. Standardizing prevents that. But standardization also changes the meaning of the components: when all variables have variance 1, the total variation is just the number of variables, and the components reflect structure rather than scale. When all the original variables are already on the same scale and units, the choice matters far less. Whichever way the discussion resolves it, the two sides of the argument are on the table: raw units can bias the components toward big-number variables, while standardization can erase genuine differences in variation between variables.

Exam Guidance Summary

  • The exam expects no full eigenvalue calculation; the worked example only shows the path behind the concept. The heavy arithmetic exists to make the method visible, not to be reproduced — understand the route from covariance matrix to characteristic equation to eigenvalues, do not memorize the arithmetic.
  • Answer only what the question requires, and address whichever part is relevant; do not add computation the question does not ask for. A question about the concept needs the concept, not a re-run of the worked example.
  • The LDA numerical problem will be simple: no extensive math to calculate, no functions or derivatives involved, and nothing like that is expected for calculation in the exam. Expect the idea — the between-versus-within ratio and the contrast with PCA — rather than heavy computation.
  • Hold onto the PCA-versus-LDA contrast: the direction of maximum variation is not the same as the direction of classification separation. This single contrast connects the two main techniques of the unit and is the safest concept to be tested on.
  • Remember the decision rule and its limit: keep principal components until about 90 percent of the total variation is explained, and recognize when that rule cannot apply — comparable shares, like 40 percent and 60 percent, make any reduction unsafe.
  • A revision session was planned to revisit the full material before the end of the term; the standardization question from 13.6 was deferred to that following session and is worth revisiting too.

Key Industry Applications

  • Real-world: PCA and LDA are used extensively in machine learning algorithms today, and the linear algebra underneath them is the standard prerequisite for understanding them. PCA remains a standard preprocessing step in modern pipelines — in face recognition (where the leading principal components of images are known as eigenfaces), in genomics (thousands of genes per sample), and in finance (hundreds of indicators per customer).
  • Real-world: high-dimensional datasets with thousands of columns are routine in practice — gene-expression studies, image data, and customer databases all fit this shape — which is exactly the situation dimensionality reduction is built for: compress the columns without losing the signal.
  • Real-world: multicollinearity is a real regression failure mode, and transforming correlated inputs into uncorrelated principal components is one standard way to avoid it. Regression models fitted on the transformed components no longer fight over which correlated variable caused which effect.
  • Real-world: the R documentation example computes eigenvalues and eigenvectors in one line; in practice the software does the arithmetic, and the concept is what you need to understand. The same applies across statistical packages: the output is the eigenvalues and the components, and the analyst's job is to read them.
  • Real-world: LDA's class-separating line is used wherever group membership must be predicted from measurements — a restaurant chain can tell prospective buyers from non-buyers, a bank can separate good from bad credit risk, and marketers can map how customers perceive competing brands.
  • Real-world: cluster analysis — maximizing inter-cluster separation and minimizing intra-cluster spread — is the standard way to group similar observations. Customer relationship management (CRM) teams use it to segment customers so each segment gets its own targeted offer, which is the same grouping-by-distance logic previewed in this lecture.

ASM Lecture 13 notes · Dimensionality Reduction, Principal Component Analysis, and Linear Discriminant Analysis

Advanced Statistical Methods· postgraduate· 2026-08-11

Sections Breakdown

113.1 Dimensionality Reduction

Rows and columns, why high-dimensional data cannot be drawn, and why a reduction earns its keep only when it keeps the information; PCA and LDA introduced.

213.2 Principal Component Analysis

PCA projects the data along the direction of maximum variation, turns correlated x's into uncorrelated z's, and the covariance-matrix recipe behind the principal directions.

313.3 Worked Example: PCA on a Two-Dimensional Dataset

Full numeric walkthrough: characteristic equation, eigenvalues 30.66 and 0.0258, eigenvectors, the 99 percent variance story, and the reduction decision rule.

413.4 Linear Discriminant Analysis

Why maximum variation can be useless for classification; between-class versus within-class variation and the LDA score line.

513.5 Cluster Analysis

Grouping observations by distance: inter-cluster and intra-cluster distance, Euclidean distance, and the caution on scaling.

613.6 Student Questions and Answers

The open question of standardizing data before PCA, and what the answer will have to weigh.

Postgraduate students in Advanced Statistical Methods

Exam Revision Notes

Below is the distilled, exam-ready core. Every entry comes from the full explanation above. Use this section for rapid review; return to the main notes when a point needs more context.

13.1 Dimensionality Reduction

Must-know: Dimensionality reduction lowers the number of attributes while keeping the maximum available information; a reduction that throws away half the information is pointless.

Top pitfall: Blindly dropping whole columns destroys information; reduction must replace many correlated columns with few that keep the signal.

Self-check: Why are PCA and LDA both taught on a two-dimensional example?

Connects to: 13.2, 13.4.

13.2 Principal Component Analysis

Must-know: PCA projects data in the direction of maximum variation, chosen by the largest eigenvalue; the transformed components z1..zn are uncorrelated, which removes multicollinearity in regression.

Top pitfall: Confusing the point-rotation convention with the axis-rotation convention puts a minus sign in the wrong entry and mirrors the first principal component; also, correlation (scale-free) must not be confused with covariance (unit-dependent).

Self-check: Why are the two principal components perpendicular to each other?

Connects to: 13.1, 13.3, 13.4.

13.3 Worked Example: PCA on a Two-Dimensional Dataset

Must-know: The share of total variation carried by component i is lambda_i over the sum of all eigenvalues; with lambda1 = 30.66 over 30.69 the first component carries about 99 percent, so z1 alone is kept and z2 ignored.

Top pitfall: Reducing dimensions when no component dominates: with comparable shares like 40 percent and 60 percent, dropping either component is not safe.

Self-check: Why does the sum of the eigenvalues (30.69) equal the sum of the diagonal entries of the covariance matrix?

Connects to: 13.2, 13.4.

13.4 Linear Discriminant Analysis

Must-know: PCA maximizes variation, LDA maximizes between-class variation relative to within-class variation; the direction of maximum variation can be useless for classification. LDA predicts group membership with a linear score Y = b0 + b1X1 + ... + bKXK.

Top pitfall: Assuming the widest direction of the data is the best direction for separating classes; overlapping projections along the maximum-variation axis make classification fail.

Self-check: Why can the direction of maximum variation be useless for classification?

Connects to: 13.2, 13.3, 13.5.

13.5 Cluster Analysis

Must-know: Cluster analysis groups observations so that inter-cluster distance is maximized and intra-cluster distance is minimized; similarity is measured by distance, and the shorter the distance the more similar the observations.

Top pitfall: Running cluster analysis on variables measured in widely different units without standardizing: the larger-unit variable dominates the distances and decides the clusters.

Self-check: Why does cluster analysis follow the same between-versus-within logic as LDA?

Connects to: 13.4, 13.6.

13.6 Student Questions and Answers

Must-know: The question of whether to standardize before PCA was left open in the lecture; the trade-off is between raw units biasing components toward large-unit variables and standardization erasing real differences in variation.

Top pitfall: Assuming the professor resolved the standardization question in this lecture — the discussion closed without an answer and was deferred to the next session.

Self-check: What does standardizing a variable do to its mean and variance?

Connects to: 13.2, 13.5.

Exam Guidance Summary

Must-know: No full eigenvalue calculation in the exam; answer only what the question asks; the LDA problem is simple with no extensive math; the PCA-versus-LDA contrast is the core idea to hold.

Top pitfall: Adding computation the question does not ask for — reproduce concepts, not the worked arithmetic.

Self-check: Why is the direction of maximum variation not the same as the direction of classification separation?

Connects to: 13.2, 13.3, 13.4.

Key Industry Applications

Must-know: PCA and LDA underpin real machine learning pipelines; dimensionality reduction exists because thousands of columns are routine; cluster analysis drives customer segmentation in CRM.

Connects to: 13.1, 13.2, 13.4, 13.5.

Was this lecture useful?

Loading comments…
🤖

BitsNotes AI Assistant

Subject Notes Assistant

Configure AI Chat

Choose how to access the chatbot
Have your own API key?

Switch to "Bring Your Own Key" tab above for unlimited access with any OpenAI-compatible provider.

🔑 Enter API key above to fetch live models from provider, or enter model name manually.
OpenAI-Compatible API Support

Choose any provider preset (Gemini, DeepSeek, Kimi, GLM, MiniMax, Qwen, OpenAI, Groq, Ollama, etc.) or enter a custom endpoint URL.

Security & Privacy First

Your API key is sent directly from your browser to your specified provider. BitsNotes servers never store or see your key.