Learn

Learning preferences

Make learning more comfortable. Changes apply immediately.

Enlarges page content, including diagrams and their labels. You can also use your browser’s zoom.

Choose the colours that are easiest for you to distinguish. Applies to lesson diagrams and lab plots. Labels, shapes, hatching and line patterns also distinguish meanings. Source photographs and raw image brightness stay unchanged; mask-only views are available for image overlays.

ExampleComparisonSample link

Saved in this browser on this device. Preferences are separate from progress backups.

Lesson 3 of 3

Choose scales and diagnose unidentified directions

Compare covariance and correlation PCA without hiding zero variance or tied eigenvalues.

Loading your saved responses…

Try

A sensor exports the same physical quantity in a new unit, doubling every number in its first column. No new observations were collected. Should a statistical summary choose a different direction?

There is no answer until we choose the geometry. Covariance PCA minimizes squared error in the numerical units supplied. Doubling a column multiplies its contribution to that squared error by four. Correlation PCA first divides each centered column by its own sample standard deviation, putting both columns on a common variability scale. That chooses a different question; standardization is not an automatic correction that makes every analysis scientifically appropriate.

Use the worked observations from centering and scores. Their original sample covariance is [[20/3,4],[4,20/3]], with first line of slope 1 and explained fraction 4/5.

Predict

Before calculation, predict which original-coordinate direction will receive more weight after doubling variable 1. The new covariance is [[80/3,8],[8,20/3]], not twice the original covariance. Its eigenvalues are

50/3 + 2√41, 50/3 − 2√41.

The first explained fraction is 1/2+3√41/50≈0.884187454246. A leading direction is proportional to ((5+√41)/4,1), closer to the first coordinate axis. Normalize this vector before using it for dot-product scores.

Now predict the standardized correlation matrix. The sample SDs are 2√(20/3) and √(20/3), giving [[1,3/5],[3/5,1]]. Its eigenvalues are 8/5 and 2/5, so its first fraction stays 4/5. Unchanged correlation describes invariance to this positive unit rescaling, not invariance of raw squared distances.

Experiment

Open the shared PCA lab. Reset, then use “Worked data: double variable 1.” This replaces the input with (26,21),(22,23),(18,17),(14,19). Compare covariance and correlation modes. The preset is a fixed dataset, not a command that doubles arbitrary learner edits. Results update as settings change.

In covariance mode the plotted coordinates are centered original units; in correlation mode they are standardized. The displayed original-unit reconstructed rows have had the scaling and mean restored. Therefore the numeric residual sum of squares in correlation mode belongs to standardized coordinates. It cannot be compared directly with raw-coordinate squared loss as though both used the same unit.

Next choose “Equal-variance directions,” which supplies the four points (1,0),(−1,0),(0,1),(0,−1). Predict why the code can draw a line even when the mathematics selects no unique one. Finally try “Constant data.” Explain the difference between a meaningful zero reconstruction error and an undefined explained fraction. Presets retain the selected scaling mode, so a constant-data correlation refusal is expected; switch to covariance to inspect the zero matrix.

Data mechanismCovariance conclusionCorrelation conclusion
One constant column; another variesRank 1; principal line defined; fraction 1Undefined division by zero SD
Every row identicalZero matrix; loss 0; fraction undefined; no preferred axisBoth SDs zero
Nonzero scalar covarianceEvery axis optimal; fraction 1/2 in two dimensionsCheck SDs and correlation matrix separately
Distinct positive eigenvaluesPrincipal line unique; loading sign arbitraryMay identify a different original-unit line

Understand

The metric behind standardization

Write a centered observation as a column x, and let D be the diagonal matrix of its two positive training sample SDs. The standardized vector is z=D⁻¹x, with covariance D⁻¹CD⁻¹. If v is its unit first loading, zhat=vvᵀz is the standardized orthogonal projection. Restore original centered coordinates by xhat=Dzhat, then restore the training mean.

The minimized residual is

||z−zhat||² = (x−xhat)ᵀD⁻²(x−xhat).

This is a weighted original-coordinate squared error. In general x−xhat is not Euclidean-perpendicular to the original-coordinate axis Dv. For example D=diag(1,2), v=(1,1)/√2 and standardized residual (1,−1) give restored residual (1,−2); its dot product with Dv=(1,2)/√2 is −3/√2. Orthogonality holds in standardized coordinates, which is exactly where the workbench draws correlation-mode projection segments.

For the doubled-first-variable worked case, the standardized first loading is (1,1)/√2. Its restored line is proportional to (2,1), different from the covariance-PCA line ((5+√41)/4,1). Both calculations can be correct because their objectives differ. A predictor’s scientific importance is not automatically its variance, and equally weighting standardized columns is a modeling choice.

Constant columns and zero total variation

Sample variance is a sum of nonnegative squared deviations. It is zero exactly when every value in that column equals its mean. Dividing by its SD is then undefined. A tool must refuse correlation PCA or explicitly offer a separately defined variable-removal procedure; replacing the SD by 1 silently changes the method.

If all centered rows are zero, C=0, every unit vector is an eigenvector and all reconstructions equal the mean. Loss is zero, but λ₁/(λ₁+λ₂)=0/0 has no value. “100% explained” would hide that there was no variation to explain.

If instead at least one centered row is nonzero and all lie on span(u), write them as a_i u with u nonzero. Then C=(Σa_i²/(n−1))uuᵀ has rank 1. The principal line is span(u), its sign is arbitrary, and its training fraction is 1. This proves only a property of the given rows, not a noise-free population or a causal latent variable.

Repeated and nearly repeated eigenvalues

For the equal-axis example, C=(2/3)I. Every unit v has vᵀCv=2/3, so all one-dimensional projections are optimal. Each loses total squared length 2 and captures fraction 1/2. Choosing the x-axis or y-axis gives different reconstructed points with exactly the same objective value.

A numerical program may flag eigenvalues as tied within a tolerance. That warning indicates unreliable axis identification at the working precision; it is not proof of exact equality. Even in exact mathematics, replacing cI by diag(c+ε,c) or diag(c,c+ε) for arbitrarily small ε>0 selects perpendicular leading axes. Thus tiny perturbations can change a selected axis substantially near a tie. Compare subspaces, projectors, eigenvalue gaps and reconstruction objectives instead of relying on a printed arrow’s sign or apparent stability.

Apply

Use rows (2,0),(2,2),(2,4). Determine every covariance-mode output you can justify, then decide whether correlation mode is defined. Explain why this case differs from the constant-data preset.

Check the distinction

The mean is (2,2); centered rows are (0,−2),(0,0),(0,2). C=diag(0,4). The first line is vertical, first scores can be −2,0,2, and reconstruction restores every original row. Positive total variation gives fraction 1 and loss 0. Correlation mode is undefined because the first SD is zero. With all rows identical, both variances and total variation would be zero, so no preferred first line or defined explained fraction would remain.

Continue

Complete the mixed PCA assessment using a written centering/scaling contract, independent reconstruction checks and a frozen validation transformation. Return to SVD and low-rank approximation for the general operator viewpoint, or regression diagnostics to distinguish explanatory data reduction from an outcome model.

These lessons implement small-sample PCA mechanisms and their boundaries. They do not supply sparse/high-dimensional PCA theory, model-based uncertainty for estimated eigenvectors or a completed real-data investigation. Those claims require their own assumptions and evidence; a high training fraction is not a substitute.

Apply · explain · revise

Practice and reasoning

Drafts save locally as you type. Reveal worked solutions when useful; the site remembers that exposure. Automatic matches check the requested answer, while written arguments require review against the rubric.

A centered covariance is [[1,1],[1,4]]. Multiply the second variable by3. Compute the new covariance and both correlation matrices. Explain why unchanged correlation does not mean unchanged covariance principal directions.

Structure your argument and preserve revisions

These optional planning fields save locally. Recording your response saves an immutable copy of the argument and these fields. Older records may contain only first/latest responses; missing intermediate revisions are not reconstructed.

Each field allows 2,000 characters. Keep a specific claim, state where it applies, cite the facts you use, and explain what still needs checking. Blank fields are allowed and are not evidence of mastery.

Let D be the positive diagonal matrix of training sample SDs. Explain correlation PCA on centered original row x via z=D⁻¹x (column notation). Prove which quadratic error is minimized after reconstruction in original units. Must the restored residual be Euclidean-perpendicular to the restored axis?

Structure your argument and preserve revisions

These optional planning fields save locally. Recording your response saves an immutable copy of the argument and these fields. Older records may contain only first/latest responses; missing intermediate revisions are not reconstructed.

Each field allows 2,000 characters. Keep a specific claim, state where it applies, cite the facts you use, and explain what still needs checking. Blank fields are allowed and are not evidence of mastery.

Analyze rows (2,0),(2,2),(2,4) in covariance and correlation modes. Then analyze three identical rows (2,2). State which outputs are mathematically defined rather than inventing zero-division fixes.

Structure your argument and preserve revisions

These optional planning fields save locally. Recording your response saves an immutable copy of the argument and these fields. Older records may contain only first/latest responses; missing intermediate revisions are not reconstructed.

Each field allows 2,000 characters. Keep a specific claim, state where it applies, cite the facts you use, and explain what still needs checking. Blank fields are allowed and are not evidence of mastery.

For observations (1,0),(−1,0),(0,1),(0,−1), prove every unit direction is a covariance principal direction, compute rank-one loss, and show two valid reconstructions differ. What can be asserted if a floating calculation labels nearly equal eigenvalues tied?

Structure your argument and preserve revisions

These optional planning fields save locally. Recording your response saves an immutable copy of the argument and these fields. Older records may contain only first/latest responses; missing intermediate revisions are not reconstructed.

Each field allows 2,000 characters. Keep a specific claim, state where it applies, cite the facts you use, and explain what still needs checking. Blank fields are allowed and are not evidence of mastery.

An analyst changes the sign of variable2, for instance reversing its axis orientation. Show how covariance, leading eigenvectors, scores and reconstruction transform, including when correlation scaling uses nonnegative SDs.

Structure your argument and preserve revisions

These optional planning fields save locally. Recording your response saves an immutable copy of the argument and these fields. Older records may contain only first/latest responses; missing intermediate revisions are not reconstructed.

Each field allows 2,000 characters. Keep a specific claim, state where it applies, cite the facts you use, and explain what still needs checking. Blank fields are allowed and are not evidence of mastery.

All centered rows lie on one nonzero line in R², and at least one centered row is nonzero. Prove covariance has rank1, characterize the principal axis and training fraction, and explain why this does not establish a noise-free population or a causal latent variable.

Structure your argument and preserve revisions

These optional planning fields save locally. Recording your response saves an immutable copy of the argument and these fields. Older records may contain only first/latest responses; missing intermediate revisions are not reconstructed.

Each field allows 2,000 characters. Keep a specific claim, state where it applies, cite the facts you use, and explain what still needs checking. Blank fields are allowed and are not evidence of mastery.

Reflect and continue

Before marking this lesson complete, explain one key idea without the worked solution and identify a condition that matters. Marking complete records participation, not independent mastery.