What is QR decomposition and how is it used for least squares?

Quick Overview

Asks what the QR decomposition of a matrix is and how it is used to solve linear least squares problems. Tests the derivation from orthogonality, numerical stability compared with the normal equations, and what happens when the design matrix is rank-deficient.

What is QR decomposition and how is it used for least squares?

Role: Data Scientist

Category: Statistics & Math

Difficulty: medium

Interview Round: Other

What is QR decomposition, and how is it used to solve a least squares problem $\min_x \|Ax - b\|_2$? ```hint Lengths under orthogonal maps Ask what multiplying a vector by an orthogonal matrix does to its length, and what that lets you do to $\|Ax - b\|$ without changing the minimizer. ``` ```hint Compare with the normal equations Think about which matrix each method actually works with, and how its condition number compares with that of $A$. ``` ### What a Strong Answer Covers - What the factorization is: the shapes and properties of $Q$ and $R$, and how it is computed in practice. - A correct derivation of the least squares solution from the factors, including what happens to the part of $b$ outside the column space of $A$. - Why QR is numerically preferred to the normal equations, stated in terms of the condition number. - What the method requires of $A$ and what to do when that requirement fails. - The cost of QR compared with the alternatives. ### Follow-up Questions - How does QR with column pivoting handle a rank-deficient design matrix? - When would you use the SVD instead of QR for least squares? - Why does classical Gram-Schmidt lose orthogonality in floating point, and how do Householder reflections avoid that? - How would you update the solution when one new row of data arrives?

Overview: Asks what the QR decomposition of a matrix is and how it is used to solve linear least squares problems. Tests the derivation from orthogonality, numerical stability compared with the normal equations, and what happens when the design matrix is rank-deficient.

General logo
General
Nov 25, 2026
mediumData ScientistOtherStatistics & Math
0
0

What is QR decomposition, and how is it used to solve a least squares problem min⁡x∥Ax−b∥2\min_x \|Ax - b\|_2?

What a Strong Answer Covers Guidance

  • What the factorization is: the shapes and properties of QQ and RR , and how it is computed in practice.
  • A correct derivation of the least squares solution from the factors, including what happens to the part of bb outside the column space of AA .
  • Why QR is numerically preferred to the normal equations, stated in terms of the condition number.
  • What the method requires of AA and what to do when that requirement fails.
  • The cost of QR compared with the alternatives.

Follow-up Questions Guidance

  • How does QR with column pivoting handle a rank-deficient design matrix?
  • When would you use the SVD instead of QR for least squares?
  • Why does classical Gram-Schmidt lose orthogonality in floating point, and how do Householder reflections avoid that?
  • How would you update the solution when one new row of data arrives?