σμimplied vol · KKmax(S−K,0)udβρᵢⱼfat tailsPnL · drawdownyield · TdSₜ = μSₜ dt + σSₜ dWₜC = S·N(d₁) − K·e⁻ʳᵀ·N(d₂)σₚ² = wᵀΣwd₁ = [ln(S/K) + (r + σ²⁄2)T] ⁄ σ√T∂V/∂t + ½σ²S²·∂²V/∂S² + rS·∂V/∂S − rV = 0Sharpe = (Rₚ − R_f) ⁄ σₚVaR₉₉ = μ − 2.33σρ = Cov(X,Y) ⁄ σₓσᵧE[Rₚ] = Σ wᵢ·E[Rᵢ]φ(x) = e^(−x²/2) ⁄ √2πE[Rᵢ] = R_f + βᵢ(E[Rₘ] − R_f)dXₜ = θ(μ − Xₜ)dt + σ dWₜσ²ₜ = ω + α·ε²ₜ₋₁ + β·σ²ₜ₋₁C − P = S − K·e⁻ʳᵀΔ = ∂V/∂S Γ = ∂²V/∂S²p = (e^(rΔt) − d) ⁄ (u − d)rₜ = ln(Pₜ ⁄ Pₜ₋₁)E[Xₜ₊₁ | ℱₜ] = Xₜf* = (bp − q) ⁄ bz = (x − μ) ⁄ σP(N=k) = λᵏe^(−λ) ⁄ k!Θ = −∂V/∂Tν = S·φ(d₁)·√Tmin wᵀΣw s.t. wᵀμ = μ*∫Σ∂∞λ
uantCraft AcademyRoadmapsSkills
Ctrl K
AO
+1.2k Learners
LoginJoin ↗
RoadmapsSkills
AO
+1.2k Learners
Login
  • English
  • Français
  • Español
  • العربية
  • Português
  • Deutsch
  • 日本語
  • 中文
σμimplied vol · KKmax(S−K,0)udβρᵢⱼfat tailsPnL · drawdownyield · TdSₜ = μSₜ dt + σSₜ dWₜC = S·N(d₁) − K·e⁻ʳᵀ·N(d₂)σₚ² = wᵀΣwd₁ = [ln(S/K) + (r + σ²⁄2)T] ⁄ σ√T∂V/∂t + ½σ²S²·∂²V/∂S² + rS·∂V/∂S − rV = 0Sharpe = (Rₚ − R_f) ⁄ σₚVaR₉₉ = μ − 2.33σρ = Cov(X,Y) ⁄ σₓσᵧE[Rₚ] = Σ wᵢ·E[Rᵢ]φ(x) = e^(−x²/2) ⁄ √2πE[Rᵢ] = R_f + βᵢ(E[Rₘ] − R_f)dXₜ = θ(μ − Xₜ)dt + σ dWₜσ²ₜ = ω + α·ε²ₜ₋₁ + β·σ²ₜ₋₁C − P = S − K·e⁻ʳᵀΔ = ∂V/∂S Γ = ∂²V/∂S²p = (e^(rΔt) − d) ⁄ (u − d)rₜ = ln(Pₜ ⁄ Pₜ₋₁)E[Xₜ₊₁ | ℱₜ] = Xₜf* = (bp − q) ⁄ bz = (x − μ) ⁄ σP(N=k) = λᵏe^(−λ) ⁄ k!Θ = −∂V/∂Tν = S·φ(d₁)·√Tmin wᵀΣw s.t. wᵀμ = μ*∫Σ∂∞λ
uantCraft AcademyRoadmapsSkills
Ctrl K
AO
+1.2k Learners
LoginJoin ↗
RoadmapsSkills
AO
+1.2k Learners
Login
  • English
  • Français
  • Español
  • العربية
  • Português
  • Deutsch
  • 日本語
  • 中文
Matrix Decompositions skill›Module 2 · SVD and low rank›Topic 2.1·~1 hrIntermediate

Singular value decomposition

Skill positionModule 2 of 5 · Topic 1 of 2
2.1 Singular value decomposition
—Lab score— / 100Total XP—Streak—

Every matrix is a rotation, a stretch and a rotation

Eigendecomposition needs a square matrix, and even then it can fail. The singular value decomposition works for every matrix, rectangular or not: A=UΣVTA=U\Sigma V^{T}A=UΣVT with UUU and VVV orthogonal and Σ\SigmaΣ diagonal with non-negative entries σ1≥σ2≥⋯≥0\sigma_1\ge\sigma_2\ge\cdots\ge0σ1​≥σ2​≥⋯≥0, the singular values. Geometrically AAA first rotates by VTV^{T}VT, then stretches each axis iii by σi\sigma_iσi​, then rotates by UUU. A unit circle becomes an ellipse whose semi-axes are the singular values.

A=UΣVT,σi=λi(ATA),∥A∥F2=∑iσi2,κ(A)=σ1σmin⁡A=U\Sigma V^{T},\qquad \sigma_i=\sqrt{\lambda_i(A^{T}A)},\qquad \lVert A\rVert_F^{2}=\sum_i\sigma_i^{2},\qquad \kappa(A)=\frac{\sigma_1}{\sigma_{\min}}A=UΣVT,σi​=λi​(ATA)​,∥A∥F2​=i∑​σi2​,κ(A)=σmin​σ1​​(1)

The columns of VVV are the eigenvectors of ATAA^{T}AATA and the columns of UUU are the eigenvectors of AATAA^{T}AAT, with eigenvalues σi2\sigma_i^2σi2​. So the SVD is the spectral theorem applied to ATAA^{T}AATA, but computed without ever forming that product, which would square the condition number and lose half the digits. Reading off facts is easy: the rank is the number of non-zero singular values, ∥A∥2=σ1\lVert A\rVert_2=\sigma_1∥A∥2​=σ1​ is the largest stretch, the Frobenius norm squared is the sum of the squared singular values, ∣det⁡A∣=∏σi|\det A|=\prod\sigma_i∣detA∣=∏σi​ for a square matrix, and the condition number σ1/σmin⁡\sigma_1/\sigma_{\min}σ1​/σmin​ measures how much AAA can amplify errors. For a m×nm\times nm×n data matrix with m≥nm\ge nm≥n, the full UUU is m×mm\times mm×m, Σ\SigmaΣ is m×nm\times nm×n and VVV is n×nn\times nn×n.

A 2 by 2 exampleTake A=(3045)A=\begin{pmatrix}3&0\\4&5\end{pmatrix}A=(34​05​). Then ATA=(25202025)A^{T}A=\begin{pmatrix}25&20\\20&25\end{pmatrix}ATA=(2520​2025​) has eigenvalues 45 and 5, so the singular values are σ1=45≈6.708\sigma_1=\sqrt{45}\approx6.708σ1​=45​≈6.708 and σ2=5≈2.236\sigma_2=\sqrt5\approx2.236σ2​=5​≈2.236. Checks: σ12+σ22=50=9+16+25=∥A∥F2\sigma_1^2+\sigma_2^2=50=9+16+25=\lVert A\rVert_F^2σ12​+σ22​=50=9+16+25=∥A∥F2​, and σ1σ2=15=∣det⁡A∣\sigma_1\sigma_2=15=|\det A|σ1​σ2​=15=∣detA∣. The condition number is σ1/σ2=3\sigma_1/\sigma_2=3σ1​/σ2​=3. If σ2\sigma_2σ2​ were 0.0010.0010.001 instead, the condition number would be about 6,700 and solving Ax=bA\mathbf x=\mathbf bAx=b would lose almost four digits.
  • SVD: every matrix is UΣVTU\Sigma V^{T}UΣVT with orthogonal UUU, VVV and non-negative sorted singular values.
  • Facts: rank is the count of non-zero σi\sigma_iσi​, ∥A∥F2=∑σi2\lVert A\rVert_F^2=\sum\sigma_i^2∥A∥F2​=∑σi2​, ∣det⁡A∣=∏σi|\det A|=\prod\sigma_i∣detA∣=∏σi​.
  • Condition number: σ1/σmin⁡\sigma_1/\sigma_{\min}σ1​/σmin​; a large value means unstable solves and unreliable inverses.
From returns to components in one callIf XXX is a T×NT\times NT×N matrix of demeaned returns, its covariance is XTX/(T−1)X^{T}X/(T-1)XTX/(T−1), so the right singular vectors of XXX are the principal directions and σi2/(T−1)\sigma_i^2/(T-1)σi2​/(T−1) are the variances along them. Taking the SVD of XXX directly gives PCA more accurately than eigendecomposing the covariance matrix, and it works even when N>TN>TN>T.

Lab · what's graded

  • The largest singular value20 pts
  • The Frobenius identity10 pts
  • The product of singular values10 pts
  • Shapes of a full SVD15 pts
  • Singular values and eigenvalues15 pts
  • A condition number15 pts
  • Why not eigendecompose AᵀA15 pts
0/ 7 answered
Tasks
1Numeric answer20 ptsNot answered

Find the largest singular value of A=(3045)A=\begin{pmatrix}3&0\\4&5\end{pmatrix}A=(34​05​), given that ATA=(25202025)A^{T}A=\begin{pmatrix}25&20\\20&25\end{pmatrix}ATA=(2520​2025​). Give it to three decimals.

sigma1=sigma_1 =sigma1​=accepted: ± 0.01
2Numeric answer10 ptsNot answered

For the same AAA, the sum of squares of all its entries equals σ12+σ22\sigma_1^2+\sigma_2^2σ12​+σ22​. What is ∥A∥F2\lVert A\rVert_F^{2}∥A∥F2​?

Frobeniussquared=Frobenius squared =Frobeniussquared=accepted: ± 0.01
3Numeric answer10 ptsNot answered

For the same AAA, the product σ1σ2\sigma_1\sigma_2σ1​σ2​ equals ∣det⁡A∣|\det A|∣detA∣. What is it?

product=product =product=accepted: ± 0.01
4Fill the blanks15 ptsNot answered

A data matrix AAA has 5 rows and 3 columns. Fill in the sizes of the factors in its full SVD A=UΣVTA=U\Sigma V^{T}A=UΣVT.

U: ×,Σ: ×,V: ×\displaystyle U:\ \htmlData{blank=a}{\phantom{\rule[-0.35em]{2.4em}{1.35em}}}\times\htmlData{blank=a}{\phantom{\rule[-0.35em]{2.4em}{1.35em}}},\qquad \Sigma:\ \htmlData{blank=a}{\phantom{\rule[-0.35em]{2.4em}{1.35em}}}\times\htmlData{blank=b}{\phantom{\rule[-0.35em]{2.4em}{1.35em}}},\qquad V:\ \htmlData{blank=b}{\phantom{\rule[-0.35em]{2.4em}{1.35em}}}\times\htmlData{blank=b}{\phantom{\rule[-0.35em]{2.4em}{1.35em}}}U: ×,Σ: ×,V: ×
5Choice15 ptsNot answered

How are the singular values of AAA related to eigenvalues?

6Numeric answer15 ptsNot answered

A matrix has singular values 6, 3 and 0.5. What is its condition number?

kappa=kappa =kappa=accepted: ± 0.01
7Explain in words15 ptsNot answered

In one or two sentences, say why computing the SVD of AAA is numerically better than eigendecomposing ATAA^{T}AATA.

Math modeKeyboard or LaTeX inputTask 1 of 7 · Ctrl ⏎ to check

Log in to run your code.

Every lecture is free to read. Create an account or log in to run code, run tests and submit this lab.

  • In-browser IDE with a bash terminal — nothing to install
  • Instant grading, XP and your place on the skill
Create an accountLog in
OR
Continue with GitHub