You are on page 1of 33

Linear Algebra and

Matrices
Methods for Dummies
21
st
October, 2009
Elvina Chu !lavia Mancini
"al# Outline

$calars, vectors and matrices

%ector and matri& calculations

'dentit(, inverse matrices


determinants

$olving simultaneous e)uations

*elevance to $+M
Linear Algebra Matrices, MfD 2009
$calar

%ariable described b( a single


number
e,g, 'ntensit( of each vo&el in an M*' scan
Linear Algebra Matrices, MfD 2009
%ector

-ot a .h(sics vector /magnitude, direction0

Column of numbers e,g, intensit( of same


vo&el at di1erent time .oints
Linear Algebra Matrices, MfD 2009
1
1
1
]
1

3
2
1
x
x
x
Matrices

*ectangular dis.la( of vectors in ro2s and


columns

Can inform about the same vector intensit( at


di1erent times or di1erent vo&els at the same
time

%ector is 3ust a n & 1 matri&


1
1
1
]
1

4 7 6
1 4 5
3 2 1
A
$)uare /4 & 40 *ectangular /4 & 20 d
i 3
5 i
th
ro2, 3
th
column
De6ned as ro2s & columns /* & C0
1
1
1
]
1

8 3
7 2
4 1
C
1
1
1
]
1

33 32 31
23 22 21
13 12 11
d d d
d d d
d d d
D
Linear Algebra Matrices, MfD 2009
Matrices in Matlab

78matri&

98end of a ro2

58all ro2 or column

,
_

9 8 7
6 5 4
3 2 1
$ubscri.ting : each element of a
matri& can be addressed 2ith a .air
of numbers9 ro2 6rst, column second
/*oman Catholic0
e,g, X(2,3) = 6
X(3, :) =
X( [2 3], 2) =

( ) 9 8 7

,
_

8
5
;$.ecial< matri&
commands5
= zeros(3,1) =

ones(2) =

magic(3) =

,
_

1 1
1 1

,
_

0
0
0
Linear Algebra Matrices, MfD 2009

,
_

2 9 4
7 5 3
6 1 8
Design matri&
=

9
+

+
Y X
d
a
t
a

v
e
c
t
o
r
d
e
s
i
g
n

m
a
t
r
i
x
p
a
r
a
m
e
t
e
r
s
e
r
r
o
r

v
e
c
t
o
r

=

t
h
e

b
e
t
a
s

(
h
e
r
e

:

1

t
o

9
)
Linear Algebra Matrices, MfD 2009
"rans.osition
1
1
1
]
1

2
1
1
b
[ ] 2 1 1
T
b
[ ] 9 4 3 d
column row row column
1
1
1
]
1

4 7 6
1 4 5
3 2 1
A
1
1
1
]
1

4 1 3
7 4 2
6 5 1
T
A
Linear Algebra Matrices, MfD 2009
1
1
1
]
1

9
4
3
T
d
Matri& Calculations
Addition
Commutative5 A>B8B>A
Associative5 /A>B0>C8A>/B>C0
1
]
1

1
]
1



+
1
]
1

1
]
1

1
]
1


1 1
1 1
1 1
1 1
2 2
2 2
1 1
1 1
2 2
2 2
A
$ubtraction
? @( adding a negative
matri&
1
]
1

1
]
1

+ +
+ +

1
]
1

+
1
]
1

+
6 5
4 3
1 5 3 2
0 4 1 2
1 3
0 1
5 2
4 2
A
Linear Algebra Matrices, MfD 2009
1
]
1

1
]
1



+
1
]
1

1
]
1

1
]
1


1 2
2 1
4 3
2 1
3 5
4 2
4 3
2 1
3 5
4 2
A
$calar multi.lication

$calar & matri& 8 scalar


multi.lication
Linear Algebra Matrices, MfD 2009
Matri& Multi.lication
When A is a mxn matrix & B is a kxl
matrix, AB is only possible if n=k. The
result will be an mxl matrix
A
1
A
2
A
4
A
A
A
B
A
C

A
D
A
E
A
9
A
10
A
11

A
12
m
n
&
@
14
@
1A
@
1B
@
1C
@
1D
@
1E
l
k
-umber of columns in A 8 -umber of ro2s in @
8 m & l matri&
Linear Algebra Matrices, MfD 2009
Matri& multi.lication

Multi.lication method5
$um over .roduct of res.ective ro2s and columns

1 0
2 3

_
,

,
_

1 3
1 2

,
_

!! !1
1! 11
c c
c c
1
]
1

+ +
+ +
1) (3 1) (2 3) (3 2) (2
1) (0 1) (1 3) (0 2) (1

,
_

5 1"
1 !
7 8
8
8
De6ne
out.ut
matri&
A B
= Matlab does all this for (ouF
= $im.l( t(.e5 C 8 A G @
Linear Algebra Matrices, MfD 2009
Matri& multi.lication

Matri& multi.lication is -O"


commutative

A@H@A

Matri& multi.lication '$ associative

A/@C08/A@0C

Matri& multi.lication '$ distributive

A/@>C08A@>AC

/A>@0C8AC>@C
Linear Algebra Matrices, MfD 2009
%ector +roducts
'nner .roduct 7
"
I is a scalar
/1&n0 /n&10
Outer .roduct 7I Outer .roduct 7I
" "
is a matri& is a matri&
/n&10 /1&n0 /n&10 /1&n0

xy
T

x
1
x
2
x
3

1
]
1
1
1
y
1
y
2
y
3
[ ]

x
1
y
1
x
1
y
2
x
1
y
3
x
2
y
1
x
2
y
2
x
2
y
3
x
3
y
1
x
3
y
2
x
3
y
3

1
]
1
1
1
[ ]
i
i
i
T
y x y x y x y x
y
y
y
x x x

+ +
1
1
1
]
1

3
1
3 3 2 2 1 1
3
2
1
3 2 1
# x
Inner product 8 scalar
Two vector:
1
1
1
]
1

3
2
1
x
x
x
x
1
1
1
]
1

3
2
1
y
y
y
y
!uter product 8 matri&
Linear Algebra Matrices, MfD 2009
'dentit( matri&
's there a matri& 2hich .la(s a similar role as the number 1 in
number multi.licationJ
Consider the n&n matri&5
!or an( n&n matri& A, 2e have A I
n
8 I
n
A 8 A
!or an( n&m matri& A, 2e have I
n
A 8 A, and A I
m
8 A /so 2 .ossible
matrices0
Linear Algebra Matrices, MfD 2009
'dentit( matri&
1 1 2 2 3 3 1 1 0 0 0 0 1+0+0 1+0+0 0+2+0 0+2+0 0+0+3 0+0+3
4 4 5 5 6 6 X X 0 0 1 1 0 0 = = 4+0+0 4+0+0 0+5+0 0+5+0 0+0+6 0+0+6
7 7 8 8 9 9 0 0 0 0 1 1 7+0+0 7+0+0 0+8+0 0+8+0 0+0+9 0+0+9
Kor#ed
e&am.le
A I
3
= A
for a 4&4
matri&5
= 'n Matlab5 e"e(r, c) .roduces an r & c identit( matri&
Linear Algebra Matrices, MfD 2009
Matri& inverse
= #e$n%t%on& A matri& A is called non%n'ul(r or
%nvert%)le if there e&ists a matri& B such that5
= *ot(t%on& A common notation for
the inverse of a matri& A is A
?1
, $o5
= "he inverse matri& is uni)ue 2hen it e&ists, $o if A is
invertible, then A
?1
is also invertible and then /A
"
0
?1
8 /A
?1
0
"
1 1 1 1 X X
2 2
3 3
-1 -1

3 3
= =
2 2 + + 1 1
3 3 3 3
-1 -1 + + 1 1
3 3 3 3
= = 1 1 0 0
-1 -1 2 2
1 1
3 3
1 1
3 3
-2 -2+ + 2 2
3 3
3 3
1 1 + + 2 2
3 3 3 3
0 0 1 1
= 'n Matlab5 A
?1
8 %nv(A) =Matri& division5 AL@8
A*B
?1
Linear Algebra Matrices, MfD 2009
Matri& inverse
= !or a 7&7 s)uare matri&5
= "he inverse matri& is5
Linear Algebra Matrices, MfD 2009
= E,g,5 2&2 matri&
Determinants
= Determinants are mathematical ob3ects that are ver( useful in
the anal(sis and solution of s(stems of linear e)uations /i,e,
MLMs0,
= "he determ%n(nt is a function that associates a scalar det/A0
to ever( s)uare matri& A,
'n.ut is n&n matri&
Out.ut is a single
number /real or
com.le&0 called the
determinant


det(M)
M
11
M
12
L M
1n
M
21
M
22
L M
2n
M M O M
M
n1
M
n2
L M
nn
sgn(
x

x)M
1x
1
M
2x
2
L M
nx
n
Linear Algebra Matrices, MfD 2009
Determinants
Determinants can onl( be found for s)uare matrices,
=!or a 2&2 matri& A, det(A) = (d+)c, Lets have at closer loo# at
that5
= A matri& A has an inverse matri& A
?1
if and onl( if det(A),-,
= 'n Matlab5 det(A) 8 det(A)
Linear Algebra Matrices, MfD 2009
a b
c d
det/A0 8
8 ad ? bc
N O
$olving simultaneous
e)uations
!or one linear e)uation ax=b 2here the un#no2n is x
and a and b are constants,
4 .ossibilities5
Linear Algebra Matrices, MfD 2009
Kith P1 e)uation and P1 un#no2n

Can use solution from the single


e)uation to solve

!or e&am.le

'n matri& form


b a x
1

1 2
5 3 2
2 1
2 1

+
x x
x x
A 7 8 @
1
]
1

1
]
1

1
]
1

1
5
2 1
3 2
2
1
x
x
7 8A
?1
@
Linear Algebra Matrices, MfD 2009
1
]
1

4
1

7 8A
?1
@

"o 6nd A
?1

-eed to 6nd determinant of matri& A

!rom earlier
/2 ?20 : /4 10 8 ?A : 4 8 ?D

$o determinant is ?D
bc ad
d c
b a
A ) det(
1
]
1

2 1
3 2
Linear Algebra Matrices, MfD 2009

A
1

1
det(A)
d b
c a

1
]
1
1
]
1

1
]
1

2 1
3 2
7
1
2 1
3 2
) 7 (
1
1
A
1
2
7
14
7
1
4
1
2 1
3 2
7
1

1
]
1

1
]
1

1
]
1

X
1
]
1

4
1
if @ is
if @ is

x
1
2
x
2
1
$o
$o
b a x
1

Linear Algebra Matrices, MfD 2009


Linear Algebra Matrices, MfD 2009
Qo2 are matrices relevant
to fM*' dataJ
-ormalisation -ormalisation
$tatistical +arametric Ma. $tatistical +arametric Ma.
'mage time?series 'mage time?series
+arameter estimates +arameter estimates
Meneral Linear Model Meneral Linear Model *ealignment *ealignment
$moothing $moothing
Design matri&
Anatomical Anatomical
reference reference
$.atial 6lter $.atial 6lter
$tatistical $tatistical
'nference 'nference
*!" *!"
. R0,0B . R0,0B
Linear Algebra Matrices, MfD 2009
Linear Algebra Matrices, MfD 2009
T
%
m
e
B!.# %'n(l
T
%
m
e
single vo&el
time series
single vo&el
time series
%o&el?2ise time series anal(sis
Model
s.eci6cati
on
Model
s.eci6cati
on
+arameter
estimation
+arameter
estimation
Q(.othesis
Q(.othesis
$tatistic
$tatistic
$+M
$+M
Qo2 are matrices relevant to fM*'
dataJ
=

9
+

+
Y X
d
a
t
a

v
e
c
t
o
r
d
e
s
i
g
n

m
a
t
r
i
x
p
a
r
a
m
e
t
e
r
s
e
r
r
o
r

v
e
c
t
o
r

Linear Algebra Matrices, MfD 2009


MLM e)uation
Qo2 are matrices relevant to fM*'
dataJ
Y
d
a
t
a

v
e
c
t
o
r
*es.onse variable
e,g @OLD signal at a
.articular vo&el
A single vo&el sam.led at
successive time .oints,
Each vo&el is considered as
inde.endent observation,
Preprocessing .
..
$ntens
it#
%
i
m
e
&
%
i
m
e
Y = X . +
Linear Algebra Matrices, MfD 2009
Qo2 are matrices relevant to fM*'
dataJ

9
X
d
e
s
i
g
n

m
a
t
r
i
x
p
a
r
a
m
e
t
e
r
s

E&.lanator(
variables
"hese are assumed to
be measured 2ithout
error,
Ma( be continuous9
Ma( be dumm(,
indicating levels of an
e&.erimental factor,
Y = X . +
$olve e)uation for S : tells us
ho2 much of the @OLD signal
is e&.lained b( 7
Linear Algebra Matrices, MfD 2009
'n +ractice

Estimate MAM-'"TDE of signal


changes

M* '-"E-$'"I levels for each vo&el


at various time .oints

*elationshi. bet2een e&.eriment


and vo&el changes are established

Calculation and notation re)uire


linear algebra
Linear Algebra Matrices, MfD 2009
$ummar(

$+M builds u. data as a matri&,

Mani.ulation of matrices enables


un#no2n values to be calculated,
I 8 7 . S > U
Observed 8 +redictors G +arameters >
Error
@OLD 8 Design Matri& G @etas > Error
Linear Algebra Matrices, MfD 2009
*eferences

$+M course htt.5LL222,6l,ion,ucl,ac,u#Ls.mLcourseL

Keb Muides
htt.5LLmath2orld,2olfram,comLLinearAlgebra,html
htt.5LL222,maths,surre(,ac,u#Le&.loreLemmas.agesLo.
tion1,html
htt.5LL222,inf,ed,ac,u#LteachingLcoursesLfmcs1L
/!ormal Modelling in Cognitive $cience course0

htt.5LL222,2i#i.edia,org

+revious MfD slides


Linear Algebra Matrices, MfD 2009

You might also like