lecture 10: point clouds, eigenvectors, pcalecture 10: point clouds, eigenvectors, pca compsci/math...

64
Lecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Upload: others

Post on 22-Aug-2020

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Lecture 10: Point Clouds, Eigenvectors, PCA

COMPSCI/MATH 290-04

Chris Tralie, Duke University

2/16/2016

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 2: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Announcements

I Group Assignment 1 Part 1, Due This Sunday 11:55 PMI Note on Assignment DifficultyI Hackathon 2/26, 2/27, or 2/28 (upcoming poll)I Choosing final projects before spring breakI Visitors Coming...

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 3: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Table of Contents

I Point Clouds Unit Overview

B Eigenvalues / EigenvectorsB Principal Component Analysis

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 4: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

What Is A Point Cloud?

Interactive Demo

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 5: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

What’s In This Unit?

Point Cloud Registration (Alignment)

Courtesy of http://www.pointclouds.org

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 6: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

What’s In This Unit?

“Shape Google” (Point Cloud Statistics)

(my undergrad senior thesis)

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 7: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

What’s In This Unit?

Symmetries

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 8: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

What’s In This Unit?

Symmetries

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 9: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

What’s In This Unit?

Symmetries

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 10: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

What’s In This Unit?

Surface Reconstruction

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 11: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

What’s In This Unit?

Surface Reconstruction

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 12: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Table of Contents

B Point Clouds Unit Overview

I Eigenvalues / Eigenvectors

B Principal Component Analysis

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 13: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Eigenvalues/Eigenvectors

Ax = λx

A is N × N matrixx is N × 1 column matrix (vector)λ is a scalar called the eigenvalue of x

B A does not change the direction of x

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 14: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Eigenvalues/Eigenvectors

Ax = λx

A is N × N matrixx is N × 1 column matrix (vector)λ is a scalar called the eigenvalue of x

B A does not change the direction of x

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 15: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Eigenvalues/Eigenvectors Example: X Scale

[2 00 1

] [01

]=

Before

After

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 16: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Eigenvalues/Eigenvectors Example: X Scale

[2 00 1

] [01

]=

[01

]Yes! λ = 1

Before After

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 17: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Eigenvalues/Eigenvectors Example: X Scale

[2 00 1

] [10

]=

Before

After

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 18: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Eigenvalues/Eigenvectors Example: X Scale

[2 00 1

] [10

]=

[20

]Yes! λ = 2

Before After

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 19: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Eigenvalues/Eigenvectors Example: X Scale

[2 00 1

] [11

]=

Before

After

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 20: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Eigenvalues/Eigenvectors Example: X Scale

[2 00 1

] [11

]=

[21

]No, changes direction

Before After

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 21: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Eigenvalues/Eigenvectors Example: Shear

[1 10 1

] [10

]=

Before

After

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 22: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Eigenvalues/Eigenvectors Example: Shear

[1 10 1

] [10

]=

[10

]Yes! λ = 1

Before After

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 23: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Eigenvalues/Eigenvectors Example: Shear

[1 10 1

] [01

]=

Before

After

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 24: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Eigenvalues/Eigenvectors Example: Shear

[1 10 1

] [01

]=

[11

]No, changes direction

Before After

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 25: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Eigenvalues/Eigenvectors Example: Flip X, Scale Y

[−1 00 2

] [10

]=

Before

After

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 26: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Eigenvalues/Eigenvectors Example: Flip X, Scale Y

[−1 00 2

] [10

]=

[−10

]Yes! λ = −1 (tricky)

Before After

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 27: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Eigenvalues/Eigenvectors Example: Flip X, Scale Y

[−1 00 2

] [01

]=

Before

After

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 28: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Eigenvalues/Eigenvectors Example: Flip X, Scale Y

[−1 00 2

] [01

]=

[02

]Yes! λ = 2

Before After

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 29: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Eigenvalues/Eigenvectors Example: Flip X, Scale Y

[−1 00 2

] [11

]=

Before

After

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 30: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Eigenvalues/Eigenvectors Example: Flip X, Scale Y

[−1 00 2

] [11

]=

[−12

]No, changes direction

Before After

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 31: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Rotation Matrix

What are the eigenvectors/eigenvalues of

A =

[cos(θ) − sin(θ)sin(θ) cos(θ)

]?

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 32: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Linear Eigen-Decomposition

Eigenvectors/eigenvalues (λ1, v1), (λ2, v2)Let

v = av1 + bv2

Then

Av = A(av1 + bv2) = aAv1 + bAv2

Av = λ1av1 + λ2bv2

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 33: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Linear Eigen-Decomposition: Example

[4 −1−1 4

]

v1 =

[−1−1

], λ1 = 3

v2 =

[−11

], λ2 = 5

Let v =

[02

]

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 34: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Spectral Theorem

If A is symmetric

that is A = AT

then all of its eigenvectors are orthogonal

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 35: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Spectral Theorem: Example

[1 22 1

]

v1 =

[−11

], λ1 = −1

v2 =

[11

], λ2 = 3

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 36: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Solving for Eigenvalues/Eigenvectors

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 37: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Table of Contents

B Point Clouds Unit Overview

B Eigenvalues / Eigenvectors

I Principal Component Analysis

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 38: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Point Cloud Centroid

Given a collection of points X = {~xi}|Ni=1Centroid ~c is the “mean point”

That is

~c[k ] =1N

N∑i=1

xi [k ]

Average each coordinate independently

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 39: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Point Cloud Centroid

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 40: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Point Cloud Centroid

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 41: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Directions of Variance

Organize point cloud into N × d matrix, each point along a row

X =

− ~x1 −− ~x2 −− ~x3 −

. . .... . . .

− ~xN −

Choose a unit column vector direction u ∈ Rd×1

Then

d = Xu

gives projections onto u

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 42: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Directions of Variance

d = Xu

gives projections onto u

dT d = (Xu)T (Xu) = uT (X T X )u

Gives the sum of squared projections onto u

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 43: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Directions of Variance: Example

1000 point example in 2D, centroid is origin

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 44: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Directions of Variance: Example

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 45: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Directions of Variance: Example

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 46: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Directions of Variance: Example

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 47: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Directions of Variance: Example

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 48: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Directions of Variance: Example

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 49: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Directions of Variance: Some Math

dT d = (Xu)T (Xu) = uT (X T X )u = uT Au

B Note that A = X T X is symmetric.B It is also positive semi-definite. All eigenvalues are real

and positiveB Let (v1, λ1), (v2, λ2), ..., (vd , λd) be the d

eigenvalue/eigenvector pairs. Then a direction u can bewritten as

u = a1v1 + a2v2 + . . .+ advd

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 50: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Directions of Variance: Some Math

dT d = (Xu)T (Xu) = uT (X T X )u = uT Au

B Note that A = X T X is symmetric.

B It is also positive semi-definite. All eigenvalues are realand positive

B Let (v1, λ1), (v2, λ2), ..., (vd , λd) be the deigenvalue/eigenvector pairs. Then a direction u can bewritten as

u = a1v1 + a2v2 + . . .+ advd

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 51: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Directions of Variance: Some Math

dT d = (Xu)T (Xu) = uT (X T X )u = uT Au

B Note that A = X T X is symmetric.B It is also positive semi-definite. All eigenvalues are real

and positive

B Let (v1, λ1), (v2, λ2), ..., (vd , λd) be the deigenvalue/eigenvector pairs. Then a direction u can bewritten as

u = a1v1 + a2v2 + . . .+ advd

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 52: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Directions of Variance: Some Math

dT d = (Xu)T (Xu) = uT (X T X )u = uT Au

B Note that A = X T X is symmetric.B It is also positive semi-definite. All eigenvalues are real

and positiveB Let (v1, λ1), (v2, λ2), ..., (vd , λd) be the d

eigenvalue/eigenvector pairs. Then a direction u can bewritten as

u = a1v1 + a2v2 + . . .+ advd

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 53: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Directions of Variance: Some Math

uT (X T X )u = uT Au

Let u = a1v1 + a2v2 + . . .+ advdand all vs are unit-norm eigenvectors

Then

uT Au = (a1v1 + a2v2 + . . .+ advd)T A(a1v1 + a2v2 + . . .+ advd)

uT Au = (a1v1+a2v2+. . .+advd)T (a1λ1v1+a2λ2v2+. . .+adλdvd)

Remembering that all vs are orthogonal

uT Au = a21λ1 + a2

2λ2 + . . .+ a2dλd

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 54: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Directions of Variance: Some Math

uT (X T X )u = uT Au

Let u = a1v1 + a2v2 + . . .+ advdand all vs are unit-norm eigenvectorsThen

uT Au = (a1v1 + a2v2 + . . .+ advd)T A(a1v1 + a2v2 + . . .+ advd)

uT Au = (a1v1+a2v2+. . .+advd)T (a1λ1v1+a2λ2v2+. . .+adλdvd)

Remembering that all vs are orthogonal

uT Au = a21λ1 + a2

2λ2 + . . .+ a2dλd

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 55: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Directions of Variance: Some Math

uT (X T X )u = uT Au

Let u = a1v1 + a2v2 + . . .+ advdand all vs are unit-norm eigenvectorsThen

uT Au = (a1v1 + a2v2 + . . .+ advd)T A(a1v1 + a2v2 + . . .+ advd)

uT Au = (a1v1+a2v2+. . .+advd)T (a1λ1v1+a2λ2v2+. . .+adλdvd)

Remembering that all vs are orthogonal

uT Au = a21λ1 + a2

2λ2 + . . .+ a2dλd

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 56: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Directions of Variance: Some Math

uT (X T X )u = uT Au

Let u = a1v1 + a2v2 + . . .+ advdand all vs are unit-norm eigenvectorsThen

uT Au = (a1v1 + a2v2 + . . .+ advd)T A(a1v1 + a2v2 + . . .+ advd)

uT Au = (a1v1+a2v2+. . .+advd)T (a1λ1v1+a2λ2v2+. . .+adλdvd)

Remembering that all vs are orthogonal

uT Au = a21λ1 + a2

2λ2 + . . .+ a2dλd

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 57: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Directions of Variance: Some Math

uT (X T X )u = uT Au

Let u = a1v1 + a2v2 + . . .+ advdand all vs are unit-norm eigenvectorsThen

uT Au = (a1v1 + a2v2 + . . .+ advd)T A(a1v1 + a2v2 + . . .+ advd)

uT Au = (a1v1+a2v2+. . .+advd)T (a1λ1v1+a2λ2v2+. . .+adλdvd)

Remembering that all vs are orthogonal

uT Au = a21λ1 + a2

2λ2 + . . .+ a2dλd

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 58: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Directions of Variance: Some Math

uT Au = a21λ1 + a2

2λ2 + . . .+ a2dλd

Assuming that ||u|| = 1 =⇒ (a21 + a2

2 + . . . a2d) = 1

Also assume that λ1 > λ2 > . . . > λd

Raffle Point Question: What should the as be to maximize thesum of squared dot products: uT Au ?

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 59: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

Principal Component Analysis

1. Stack points in rows.2. Compute the “covariance matrix” A = X T X3. Compute eigenvalues/eigenvectors of A, sorted indecreasing orderOrthogonal directions of variance are in the eigenvectorsSum of squared dot products with directions areassociated eigenvalues

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 60: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

PCA Example

Largest direction of variance, λ1 = 422

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 61: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

PCA Example

Smallest direction of variance, λ2 = 21.6

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 62: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

PCA: Interactive Examples 2D/3D

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 63: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

PCA Pitfalls

Outliers!(Show Demo Again)

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA

Page 64: Lecture 10: Point Clouds, Eigenvectors, PCALecture 10: Point Clouds, Eigenvectors, PCA COMPSCI/MATH 290-04 Chris Tralie, Duke University 2/16/2016 COMPSCI/MATH 290-04 Lecture 10: Point

PCA Pitfalls

Close Eigenvectors“Multiplicity issues” for “near-isotropic” point clouds

COMPSCI/MATH 290-04 Lecture 10: Point Clouds, Eigenvectors, PCA