pca_components

std.stats.pca_components · Level L4

The principal axes of a data set, as columns, largest variance first: the right singular vectors of the centred data, each signed so its largest component is positive.

X − X̄ = U·S·Vᵀ, axes = V

Signature

pca_components(X: f64[p+k, p]) → f64[p, p]

Structure

The function as NOVA stores it: one box per input, operation and output, and arrows that carry values. A double border marks another library function this one runs — called once, or by Scan once per element; select it to open that function.

Xf64[p+k, p]MeanmuSubtractXcSVDRightVectorsVVf64[p, p]
  • input
  • operation
  • constant
  • call
  • output

Verification

  • Signature proven by NOVA’s shape solver, for every size.
  • Agrees with the reference eigh(Xcᵀ·Xc) vectors, largest first, signs fixed to 80 digits (100-digit arithmetic), on all 40 test cases.
  • All 1,018 float64 results inside the running error bound; the closest uses 10% of it.
  • Interpreter and NumPy backend return bit-identical results.
Accuracy in detail
correctly rounded (the float64 nearest the exact value)
7%
bit-equal to the NumPy formula in float64
6%
largest error, in units in the last place
1.3e+4

Large ulp counts appear where a result is zero or tiny next to the numbers it is computed from (after cancellation, for example), so one unit in the last place is tiny too; the absolute error is still inside the bound.

Note

The axes come from the SVD of the centred data; the reference takes the eigenvectors of its scatter matrix instead, so two different routes have to agree. Too-close variances, or a sign that could flip, are refused.

Identity

Calls
—
Called by
—
sha256:afa30853e74e67344203c65c539f903117a39fd5c9f84a2348b7c43e9e3103a1

The semantic hash of the graph. It changes when the program changes, and never when only its documentation does.