studEE16A
  • Introduction
  • Linear Algebra
    • Linear Equations
      • Description
      • Example Problems
    • Vector Spaces
      • Description
      • Example Problems
    • Inner Products
      • Description
      • Example Problems
    • Determinants
      • Description
      • Example Problems
    • Eigen-everything
      • Description
      • Example Problems
    • Matrices
      • Description
      • Example Problems
    • Least Squares
      • Description
      • Example Problems
    • Gram-Schmidt
      • Description
      • Example Problems
    • Basis
      • Description
      • Example Problems
    • Page Rank
  • Circuits
    • Circuit Basics
    • Capacitance
    • Nodal Analysis
    • Superposition
    • Thevenin and Norton
    • What, When, Where, and Why?
    • Op Amps
Powered by GitBook
On this page

Was this helpful?

  1. Linear Algebra
  2. Least Squares

Description

PreviousLeast SquaresNextExample Problems

Last updated 5 years ago

Was this helpful?

Let's try to understand how least squares works in one dimension.

Projection

In this example, we're trying to predict a⃗\vec{a}a based off of b⃗\vec{b}b. However, a⃗\vec{a}a has components that are not in span{b⃗}\text{span}\{\vec{b}\}span{b}, making it impossible to estimate a⃗\vec{a}a completely accurately. Our best estimate would be a1⃗\vec{a_1}a1​​, i.e. the component of a⃗\vec{a}a that is in span{b⃗}\text{span}\{\vec{b}\}span{b}. The error between a⃗\vec{a}a and a⃗1\vec{a}_1a1​ is denoted by a⃗2\vec{a}_2a2​, which is perpendicular to b⃗\vec{b}b as that minimizes its norm and the error.

We know that a⃗1\vec{a}_1a1​ must be a multiple of b⃗\vec{b}b as it is in span{b}⃗\text{span}\{\vec{b\}}span{b}​. This means that a⃗1=xb⃗\vec{a}_1 = x \vec{b}a1​=xb where xxx is a constant. Let's try solving for xxx. Since a⃗2\vec{a}_2a2​ is orthogonal to b⃗\vec{b}b, we know that their dot product is 000. Hence,

a⃗2⋅b⃗=(a⃗−a⃗1)⋅b⃗=(a⃗−xb⃗)⋅b⃗=0\vec{a}_2 \cdot \vec{b} = (\vec{a} - \vec{a}_1) \cdot \vec{b} = (\vec{a} - x \vec{b}) \cdot \vec{b} = 0a2​⋅b=(a−a1​)⋅b=(a−xb)⋅b=0

Rearranging this equation to solve for xxx gives us x=(a⃗Ta⃗)−1a⃗Tb⃗x = (\vec{a}^T\vec{a})^{-1}\vec{a}^T\vec{b}x=(aTa)−1aTb.

This same concept can be applied to higher dimensions as well by simply replacing a⃗\vec{a}a

by A\textbf{A}A where

A=[a⃗1⋯a⃗n]\textbf{A} = \begin{bmatrix}\vec{a}_1 & \cdots & \vec{a}_n\end{bmatrix}A=[a1​​⋯​an​​]

The general form for least squares is therefore

ATAx⃗=ATb⃗\textbf{A}^T\textbf{A}\vec{x} = \textbf{A}^T\vec{b}ATAx=ATb or x⃗=(ATA)−1ATb⃗\vec{x} = (\textbf{A}^T\textbf{A})^{-1}\textbf{A}^T\vec{b}x=(ATA)−1ATb.

Note: Refer to the lecture notes to see the general derivation.