Skip to content
BIASED
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 .ipynb

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 · Данные: A∈R4×3A\in\mathbb R^{4\times 3} из RNG.

A1=σ1u1v1⊤A_1=\sigma_1 u_1 v_1^\top.

Ожидаемые числа (seed 0)
Quantity Value Tolerance
∥A−A1∥F\|A-A_1\|_F ≈0.98370756\approx 0.98370756 abs ≤ 1e-6
rank(A1)(A_1) 11 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(A1)=1(A_1)=1