Lecture 3 Nearest Neighbor Algorithms

Lecture 16
Cramer’s Rule, Eigenvalue and
Eigenvector
Shang-Hua Teng
Determinants and Linear System
Cramer’s Rule
 a11 a12
a
 21 a22
a31 a32
a13   x1   b1 
 a11 a12
a23   x2   b2   a21 a22
a31 a32
a33   x3  b3 
x1 
 b1
det b2
b3
a13   x1
a23   x2
a33   x3
a12
a22
a32
a12
 a11
det a21 a22
a31 a32
a13 
a23 
a33 
a13 
a23 
a33 
0 0  b1
1 0  b2
0 1 b3
a12
a22
a32
a13 
a23 
a33 
Cramer’s Rule
• If det A is not zero, then Ax = b has the unique
solution
det[ a1 ,  , ai 1 , b, ai 1 ,  an ]
xi 
det A
i  1,2,..., n
Cramer’s Rule for Inverse
A 
1
ij

C ji
det A
i, j  1,2,..., n
Proof:
A 
1
ij

det[ a1 ,, ai 1 , e j , ai 1 , an ]
det A
Where Does Matrices Come From?
Computer Science
• Graphs: G = (V,E)
Internet Graph
View Internet Graph on Spheres
Graphs in Scientific Computing
Resource Allocation Graph
Road Map
Matrices Representation of graphs
Adjacency matrix:
A  (aij ) ,
aij  # ij edges
Adjacency Matrix:
1
5
4
1
Aij  
0
0
2
1

A  1

3
0
1
if (i, j) is an edge
if (i, j) is not an edge
1 1 0 1

0 1 0 0
1 0 1 0

0 1 0 1
0 0 1 0
Matrix of Graphs
Adjacency Matrix:
• If A(i, j) = 1: edge exists
Else A(i, j) = 0.
1
2
4
1
2
4
-3
3
3
0

0
0

1

1 0 0

0 1 1
0 0 0


0 1 0
Laplacian of Graphs
1
5
2
3
4
 3  1  1 0  1
 1 2  1 0 0 


L   1  1 3  1 0 


 0 0  1 2  1
 1 0 0  1 0 
Matrix of Weighted Graphs
Weighted Matrix:
• If A(i, j) = w(i,j): edge exists
Else A(i, j) = infty.
1
2
4
1
2
4
-3
3
3
0




2

 

0  3 4
 0 


 3 0
1
Random walks
How long does it take to get completely lost?
Random walks Transition Matrix
1
2
6
4
5

0
1

2
0

P
0

0
3

1

2
1
3
0
0
0
1
2
1
4
1
4
1
3
1
3
0
1
2
0
0
0
0
0
1
4
1
4
0
0
0
1
2
0
1
2
1
3

0

0

1

3
1
3

0

Markov Matrix
• Every entry is non-negative
• Every column adds to 1
• A Markov matrix defines a Markov chain
Other Matrices
• Projections
• Rotations
• Permutations
• Reflections
Term-Document Matrix
• Index each document (by human or by
computer)
– fij counts, frequencies, weights, etc
doc 1
term 1  f11
term 2  f 21
  

term m  f m1
doc2

doc n
f12

f 22



fm2

f1n 
f 2 n 
 

f mn 
• Each document can be regarded as a point
in m dimensions
Document-Term Matrix
• Index each document (by human or by
computer)
– fij counts, frequencies, weights, etc
doc 1 
doc 2 
 

doc m 
term 1
term 2

term n
f11
f12

f 21
f 22




f m1
fm2

f1n 
f 2 n 



f mn 
• Each document can be regarded as a point
in n dimensions
Term Occurrence Matrix
human
interface
computer
user
system
response
time
EPS
survey
trees
graph
minors
c1
1
1
1
0
0
0
0
0
0
0
0
0
c2
0
0
1
1
1
1
1
0
1
0
0
0
c3
0
1
0
1
1
0
0
1
0
0
0
0
c4
1
0
0
0
2
0
0
1
0
0
0
0
c5
0
0
0
1
0
1
1
0
0
0
0
0
m1
0
0
0
0
0
0
0
0
0
1
0
0
m2
0
0
0
0
0
0
0
0
0
1
1
0
m3
0
0
0
0
0
0
0
0
0
1
1
1
m4
0
0
0
0
0
0
0
0
1
0
1
1
Matrix in Image Processing
Random walks
1 
0 
 
0 
 
0 
0 
 
0 
How long does it take to get completely lost?
Random walks Transition Matrix
1
6
4
5

2
0
1

2
0

P
0
3
0

1

2
1
3
0
0
0
1
2
1
4
1
4
1
3
1
3
0
0
0
1
2
0
0
0
1
4
1
4
0
0
0
1
2
0
1
2
1
3

0

0

1

3
1
3

0

100
1 
0 
 
0 
 
0 
0 
 

0 
