Back to topic
Optional
SVD rank-1 reconstruction
Build σ1 u1 v1ᵀ; compare Frobenius error to the full matrix.
- Version
- v1
- Minutes
- ~20
- Evidence
- Self-check in the notebook
Until platform auto-check exists, compare cell output with the expected numbers in the notebook. This is not a debt and does not affect mastery.
Download the notebook and run it locally. Its environment requirements are listed inside.
Notebook contents
Readable on your phone. The code below has not been executed in the browser; download the notebook to run it.
Math · SVD ранговая-1 реконструкция / SVD rank-1 reconstruction
Activity version: 1 · Seed: 0 · Данные: из RNG.
.
Ожидаемые числа (seed 0)
| Quantity | Value | Tolerance |
|---|---|---|
| abs ≤ 1e-6 | ||
| rank | exact |
Самопроверка в ноутбуке
Не влияет на mastery.
import numpy as np
rng = np.random.default_rng(0)
A = rng.normal(size=(4, 3))
U, S, Vt = np.linalg.svd(A, full_matrices=False)
A1 = S[0] * np.outer(U[:, 0], Vt[0, :])
err = np.linalg.norm(A - A1, "fro")
rank1 = np.linalg.matrix_rank(A1, tol=1e-10)
print("err", err, "rank", rank1)
assert abs(err - 0.98370756048056) < 1e-6
assert rank1 == 1
print("OK: SVD rank-1")Самопроверка в ноутбуке
- Frobenius-ошибка ≈ 0.9837
- rank