mat 2401 linear algebra 2.5 applications of matrix operations

24
MAT 2401 Linear Algebra 2.5 Applications of Matrix Operations http://myhome.spu.edu/lauw

Upload: jacob-fitzgerald

Post on 18-Jan-2018

230 views

Category:

Documents


0 download

DESCRIPTION

Preview We will only focus on one application – The Method of Least Squares.

TRANSCRIPT

Page 1: MAT 2401 Linear Algebra 2.5 Applications of Matrix Operations

MAT 2401Linear Algebra

2.5 Applications of Matrix Operations

http://myhome.spu.edu/lauw

Page 2: MAT 2401 Linear Algebra 2.5 Applications of Matrix Operations

HW Written Homework

Page 3: MAT 2401 Linear Algebra 2.5 Applications of Matrix Operations

Preview We will only focus on one

application – The Method of Least Squares.

Page 4: MAT 2401 Linear Algebra 2.5 Applications of Matrix Operations

Linear RegressionSuppose that a scientist has reason to believe that 2 quantities x and y are related linearly, that is,

y=mx+b.The scientist performs an experiment and collect data points (x1,y1),…,(xn,yn).

Page 5: MAT 2401 Linear Algebra 2.5 Applications of Matrix Operations

Linear Regressiony

x

,i ix y y mx b

ie

i i ie y mx b

Page 6: MAT 2401 Linear Algebra 2.5 Applications of Matrix Operations

Goals Find a line y=mx+b that minimize

the sum of the squares of the errors ei.

Use y=mx+b to estimate the function values.

Page 7: MAT 2401 Linear Algebra 2.5 Applications of Matrix Operations

Linear Regressiony

x

,i ix y y mx b

ie

i i ie y mx b

Page 8: MAT 2401 Linear Algebra 2.5 Applications of Matrix Operations

Matrix Equation

i i ie y mx b

Page 9: MAT 2401 Linear Algebra 2.5 Applications of Matrix Operations

Matrix Equation

1 11

2 22

11 Let , , ,

1 nn n

y exy ex b

Y X A Em

xy e

Page 10: MAT 2401 Linear Algebra 2.5 Applications of Matrix Operations

Matrix Form of Linear RegressionFor the linear regression model , the coefficients of the least squares regression line are given by

A= (XTX)-1XTYand the sum of squared error is

ETE1 11

2 22

11 Let , , ,

1 nn n

y exy ex b

Y X A Em

xy e

Page 11: MAT 2401 Linear Algebra 2.5 Applications of Matrix Operations

Plan… Computational Example HW Why the formula is correct? Very

Educational; Focus on the Ideas

Page 12: MAT 2401 Linear Algebra 2.5 Applications of Matrix Operations

Example 1Find the least squares regression line for the points (1,1), (2,2), (3,4), and (5,6).

1 11

2 22

1

11 Let , , ,

1

Then,

nn n

T T

y exy ex b

Y X A Em

xy e

A X X X Y

Page 13: MAT 2401 Linear Algebra 2.5 Applications of Matrix Operations

Example 1

Page 14: MAT 2401 Linear Algebra 2.5 Applications of Matrix Operations

Example 1

9 27 7

y x

Page 15: MAT 2401 Linear Algebra 2.5 Applications of Matrix Operations

Why? Give you some ideas why the

formula actually work.

Page 16: MAT 2401 Linear Algebra 2.5 Applications of Matrix Operations

Recall Q: How to find the minimum of a

function f(x)? A:

Page 17: MAT 2401 Linear Algebra 2.5 Applications of Matrix Operations

Recall Q: How to find the minimum of a

function f(x)? A: Q: How to find the minimum of a

function f(x,y)?

Page 18: MAT 2401 Linear Algebra 2.5 Applications of Matrix Operations

Recall: Sigma Notation A “compact” notation for sums to

avoid “…”30

2 2 2 2 2

1

1 2 3 30k

k

Page 19: MAT 2401 Linear Algebra 2.5 Applications of Matrix Operations

Recall: Sigma Notation

1 21

n

i ni

x x x x

Final value (upper limit)

Initial value (lower limit)Index

Page 20: MAT 2401 Linear Algebra 2.5 Applications of Matrix Operations

Recall: Linear Property 1

1 2

1 2

1

1

5

5

5 5 5

5

n

ii

n

ii

n

n

x x x

x

x

xx x

Page 21: MAT 2401 Linear Algebra 2.5 Applications of Matrix Operations

Recall: Linear Property 2

1 1 2 2

1 2 1

1

1 1

2

n n

n

n

i ii

n n

i ii i

n

x y x y x y

x x x y y y

x y

x y

Page 22: MAT 2401 Linear Algebra 2.5 Applications of Matrix Operations

Why? Let g(b,m) be the function of the

sum of the squared errors. We can find the critical point by

solving the equations0 and 0g g

b m

Page 23: MAT 2401 Linear Algebra 2.5 Applications of Matrix Operations

Why? Let g(b,m) be the function of the

sum of the squared error. We can find the critical point by

solving the equations

It can be shown that the critical point is a minimum (skip)

0 and 0g gb m

Page 24: MAT 2401 Linear Algebra 2.5 Applications of Matrix Operations

Why?

0 and 0g gb m

2

1

2

1

2

1

( , )n

ii

n

i ii

n

i ii

g b m e

y mx b

y mx b