Presentation is loading. Please wait.

Presentation is loading. Please wait.

Matrix Algebra Methods for Dummies FIL November 17 2004 Mikkel Wallentin

Similar presentations


Presentation on theme: "Matrix Algebra Methods for Dummies FIL November 17 2004 Mikkel Wallentin"— Presentation transcript:

1 Matrix Algebra Methods for Dummies FIL November 17 2004 Mikkel Wallentin mikkel@pet.auh.dk

2 Sources www.sosmath.com www.mathworld.wolfram.com www.wikipedia.org Maria Fernandez’ slides (thanks!) from previous MFD course: http://www.fil.ion.ucl.ac.uk/spm/doc/mfd- 2004.html http://www.fil.ion.ucl.ac.uk/spm/doc/mfd- 2004.html Slides from SPM courses: http://www.fil.ion.ucl.ac.uk/spm/course/ http://www.fil.ion.ucl.ac.uk/spm/course/

3 Design matrix … =  +  =  + YX data vector design matrix parameters error vector  = the betas (here : 1 to 9)

4 Scalars, vectors and matrices Scalar: Variable described by a single number – e.g. Image intensity (pixel value) Vector: Variable described by magnitude and direction Square (3 x 3)Rectangular (3 x 2) d i j : i th row, j th column 3 2 Matrix: Rectangular array of scalars

5 Matrices A matrix is defined by the number of Rows and the number of Columns (eg. a (mxn) matrix has m rows and n columns). A square matrix of order n, is a (nxn) matrix.

6 Addition (matrix of same size) –Commutative: A+B=B+A –Associative: (A+B)+C=A+(B+C) Eg. Matrix addition

7 Matrix multiplication Rule: In order to perform the multiplication AB, where A is a (mxn) matrix and B a (kxl) matrix, then we must have n=k. The result will be a (mxl) matrix. Multiplication of a matrix and a constant:

8 …Each parameter (the betas) assigns a weight to a single column in the design matrix … =  +  =  + YX data vector design matrix parameters error vector  = the betas (here : 1 to 9)

9 Transposition column → rowrow → column

10 Outer product = matrix Inner product = scalar Two vectors: Example Note: (1xn)(nx1) -> (1X1) Note: (nx1)(1xn) -> (nXn)

11 …A contrast estimate is obtained by multiplying the parameter estimates by a transposed contrast vector … =  +  =  + YX data vector design matrix parameters error vector   contrast vector c

12 SPM{t} A contrast = a linear combination of parameters: c T   c T = 1 0 0 0 0 0 0 0 divide by estimated standard deviation T test - one dimensional contrasts - SPM{t} T = contrast of estimated parameters variance estimate T = s 2 c(XX) + c s 2 c T (X T X) + c cbcTbcbcTb box-car amplitude > 0 ? =   > 0 ? => Compute 1 x b  + 0 x b  + 0 x b  + 0 x b  + 0 x b  +... and b  b  b  b  b ....

13 Identity matrices Is there a matrix which plays a similar role as the number 1 in number multiplication? Consider the nxn matrix : For any nxn matrix A, we have A I n = I n A = A For any nxm matrix A, we have I n A = A, and A I m = A

14 H 0 :  3-9 = (0 0 0 0...) c T = SPM{F} tests multiple linear hypotheses. Ex : does DCT set model anything? F-test (SPM{F}) : a reduced model or... multi-dimensional contrasts ? test H 0 : c T  b = 0 ? X 1 (  3-9 ) X0X0 This model ?Or this one ? H 0 : True model is X 0 X0X0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1

15 Inverse matrices Definition. A matrix A is called nonsingular or invertible if there exists a matrix B such that: Notation. A common notation for the inverse of a matrix A is A -1. So: The inverse matrix is unique when it exists. So if A is invertible, then A -1 is also invertible and

16 Determinants Recall that for 2x2 matrices: Determinants are mathematical objects that are very useful in the analysis and solution of systems of linear equations (i.e. GLMs).systems of linear equations The determinant is a function that associates a scalar det(A) to every square matrix A.functionscalarsquare matrix The fundamental geometric meaning of the determinant is as the scale factor for volume when A is regarded as a linear transformation.volumelinear transformation A matrix A has an inverse matrix A -1 if and only if det(A)≠0. Determinants can only be found for square matrices. For a 2x2 matrix A, det(A) = ad-bc. Lets have at closer look at that: And generally :

17 Matrix Inverse - Calculations A general matrix can be inverted using methods such as the Gauss-Jordan elimination, Gaussian elimination or LU decomposition i.e. Note: det(A)≠0

18 System of linear equations Imagine a drink made of egg, milk and orange juice. Some of the properties of these ingredients are described in this table: If we now want to make a drink with 540 calories and 25 g of protein, the problem of finding the right amount of the ingredients can be formulated like this: or

19 A similar problem … =  +  =  + YX data vector design matrix parameters error vector  = the betas (here : 1 to 9)

20 Cramer’s rule Consider the linear system (in matrix form) A X = B where A is the matrix coefficient, B the nonhomogeneous term, and X the unknown column-matrix. We have: Theorem. The linear system AX = B has a unique solution if and only if A is invertible. In this case, the solution is given by the so-called Cramer's formulas: where xi are the unknowns of the system or the entries of X, and the matrix Ai is obtained from A by replacing the ith column by the column B. In other words, we have where the bi are the entries of B. Thank you Bent Kramer!


Download ppt "Matrix Algebra Methods for Dummies FIL November 17 2004 Mikkel Wallentin"

Similar presentations


Ads by Google