Behavioural Genetic Interactive Modules
MatricesOverviewThis module aims to familiarise individuals with some of the common operations in matrix algebra.TutorialThis module allows the user to perform some of the more common matrix operations, such as matrix addition, multiplication, inversion and transposition. Some of these functions operate on only one matrix, such as inversion, whereas some take two matrices to produce a resulting matrix, such as addition. Also, certain operations require the matrix or matrices to have certain properties, such as being square, of having nonzero diagonal elements.Firstly, select the type of matrix operation you wish to perform: use the pull-down menu in the top-middle of the screen. For example, we choose to multiply two matrices together in this instance. As matrix multiplication is a function that takes two matrices to produce a resulting product matrix, both matrices A and B remain on screen. Matrix B will disappear if a function is selected that requires only one matrix (these are called unary functions, as opposed to binary functions).
We can define the sizes of matrices A and B using the arrows in the Matrix A and Matrix B panels. The maximum number of rows and columns is four. Also, certain predefined types of matrix can be selected from the pull-down menu in each panel. [Not operational yet] The different types of matrix are described below :
Upon selecting the type of function, some text will be displayed in the middle window, telling the user whether or not there are any special conditions required for that type of operation. In this case, for multiplication to be possible between two matrices (we say that they are conformable for multiplication) the first matrix must have the same number of columns as the second matrix has rows. Different functions have different requirements:
Let's consider the example of matrix multiplication. We know that Matrix A must have the same number of columns as Matrix B has rows. In this case, Matrix A has 2 rows and 4 columns, whereas Matrix B has 4 rows and 2 columns. They are conformable for multiplication. The resulting matrix will have as many rows as matrix A and as many columns as matrix B. It is always common to write the number of rows before columns when talking about the dimension of a matrix. Therefore : Matrix A Matrix B R C R C 2 4 4 2 | | equal? | | | |---------| | | | |-----------------| dimension of productThe two inner numbers must be equal, the resulting matrix has the dimension given by the two outer numbers. In our example, we expect a 2-by-2 matrix to result, therefore. Matrix multiplication is introduced in the Appendix: remember that the basic principle is that the ith, jth element in the resulting matrix is the sum of the products of all the elements in the ith row in Matrix A with the corresponding element in the jth column of Matrix B. In this case:
I = A * A~where I is an identity matrix, A is a symmetric, square matrix and A~ is its inverse. This is the definition of a reciprocal, that is the inverse represents, in non-matrix notation, 1/a. Try this with some real numbers using the module. That is, make up a square symmetric matrix, calculate its inverse, then multiply the matrix by its inverse. Ignoring rounding errors, the resulting matrix will always be an identity matrix. The transpose of a matrix (X') simply turns a matrix on its side: all the rows become columns and all the columns become rows. This is often useful in matrix operations. The equivalent of 'squaring' a lower triangular is X*X'. As covered in the Appendix, we can also standardise matrices, by dividing the [i,j] elements by the square root of the product of elements [i,i] and [j,j]. This has the effect of making all diagonal elements 1. In this case of a covariance matrix, standardisation will produce a correlation matrix, where all the off diagonal elements are less then 1. The quadratic product and Kronecker product are not covered in this tutorial, nor implemented in the module yet.
Questions
AnswersSite created by S.Purcell, last updated 6.11.2000 |