Cogsci 131 Linear Algebra: Tom Griffiths
Cogsci 131 Linear Algebra: Tom Griffiths
Cogsci 131 Linear Algebra: Tom Griffiths
Linear algebra
Tom Griffiths
Outline
Vectors
Break
Matrices
Vectors
A vector is an efficient way of expressing a set
of values of different features or dimensions
" x1 %
#1&
x =$ '
e.g. x = % (
# x2 &
$ 1'
Often, it is helpful to think of a vector as
corresponding to a point in space
x2
x1
x
1
1.5
$
'
$
'
$
'
x2
x1
x
ax
Adding vectors
" x1 + y1 %
x + y =$
'
# x2 + y2 &
# 1 & # 2 & # 1+ 2 & # 3 &
% (+% (=%
(=% (
1
1
1+
1
2
$
'
$
'
$
'
$
'
y
x
x+y
Linear combinations
"1%
v1 = $ '
#2&
" 3%
v2 = $ '
# 2&
"9%
u=$ '
#10&
c1,c2 > 0
any c1,c2
Linear combinations
A vector v is a linear combination of v1, , vn if
there are c1, , cn s.t. v = c1v1 + c2v2 + + cnvn
The set of all linear combinations is the span
of v1, , vn
e.g. the span of
"1%
$ '
#0&
and
"0%
$ 'is
#1&
"1%
$ '
#0&
and
"0%
$ ' form
#1&
Inner products
" y1 % T
y = $ ' y = ( y1 y 2 )
# y2 &
transpose
(y in Matlab)
" x1 % T
x = $ ' x = ( x1 x 2 )
x
#
2&
inner
"
%
x
1
y T x = ( y1 y 2 )$ ' = y1 x1 + y 2 x 2
# x2 &
Length
x T x = x12 + x 22
2
1
x = x x= x +x
2
2
Angle
The cosine of the angle between two vectors
is given by
xT y
cos( ) =
x y
So
x T y = x y cos( )
commutativity
x (y1 + y 2 ) = x y1 + x y 2
linearity
Break
Up next:
Matrices
Matrices
y = Wx
y2
y
y1
" y1 %
y =$ '
# y2 &
x2
x1
x
" x1 %
x =$ '
# x2 &
Matrix multiplication
y = Wx
y2
" x1 %
" y1 %
" w11 w12 %
y =$ ' W =$
' x =$ '
# x2 &
# y2 &
# w 21 w 22 &
y1
y = Wx
x
x1
x
y1 = w11 x1 + w12 x 2
y 2 = w 21 x1 + w 22 x 2
Matrix multiplication
inner
"
%
x
1
T
y
x = ( y1 y 2 )$ ' = y1 x1 + y 2 x 2
x
# x2 &
outer
" y1 %
" y1 x1 y1 x 2 %
x
T
yx = $ '( x1 x 2 ) = $
'
x
# y2 &
# y 2 x1 y 2 x 2 &
" aw11
aW = $
# aw 21
aw12 %
'
aw 22 &
Addition of matrices
w12 + m12 %
'
w 22 + m22 &
(W + M)x = Wx + Mx
Matrix multiplication
Basic rules follow from multiplication of a
vector by a matrix
W(M + N) = WM + WN
(M + N)W = MW + NW
Linearity
A function f is linear if:
f(cx) = cf(x)
f(x + y) = f(x) + f(y)
A function using matrix multiplication (with
inner products as a special case) is linear
In fact, any linear function can be represented
using matrix multiplication
Linear algebra: the math of linear functions
Wv = v
eigenvector
eigenvalue
"1%
"0%
are $0' and $1'
# &
# &
" 3 0%
e.g.
D=$
'
#0 4 &
Thursday
Semantic networks and spreading activation
We will use some linear algebra