Skip to main content

10.6b PCA labs

Source: Lab ideas from Computational Physics (Landau, Páez, Bordeianu), §10.6. Iris warmup + Smith 2D PCA demo. Continues 10.6.

Explorer​

Pure Python. No NumPy.

Iris warmup (18×418\times 4)​

Use this fixed table (sepal length, sepal width, petal length, petal width):

5.1 3.5 1.4 0.2
4.9 3.0 1.4 0.2
4.7 3.2 1.3 0.2
4.6 3.1 1.5 0.2
5.0 3.6 1.4 0.2
5.4 3.9 1.7 0.4
4.6 3.4 1.4 0.3
5.0 3.4 1.5 0.2
4.4 2.9 1.4 0.2
4.9 3.1 1.5 0.1
5.4 3.7 1.5 0.2
4.8 3.4 1.6 0.2
4.8 3.0 1.4 0.1
4.3 3.0 1.4 0.1
5.8 4.0 1.2 0.2
5.7 4.4 1.5 0.4
5.4 3.9 1.3 0.4
5.1 3.5 1.4 0.3

Formula refresh​

Warm up: pick the matching equation among lookalikes (same walk as the theory lesson).

Labs​

Activity: zˉ\bar z

Print the mean of column 0 (sepal length) with 10 decimals. Use N=18N=18.

No input.

Smith 2D PCA demo​

Fixed N=10N=10 points (x,y)(x,y) (Smith / textbook demo):

2.5 2.4
0.5 0.7
2.2 2.9
1.9 2.2
3.1 3.0
2.3 2.7
2.0 1.6
1.0 1.1
1.5 1.6
1.1 0.9

Pipeline: center → CC → eigenvalues / unit PC1\mathbf{PC}_1 (flip so first component <0<0) → project.

Activity: xˉ\bar x

Print the mean of the xx column with 10 decimals.

No input.

Write-ups​

0/4 solved
10.6b.W1

Using “covariance”, “eigen”, and “pc”, explain:

After building the covariance matrix of centered features, what linear-algebra step yields the principal components?

Minimum 3 words. Your answer must include: “covariance”, “eigen”, “pc”.

0 words/ 3 min

Meet the writing requirements, then you can open the model answer.

Next: 10.7 Wavelet code sketches.