Presentation is loading. Please wait.

Presentation is loading. Please wait.

Linear Algebra Review.

Similar presentations


Presentation on theme: "Linear Algebra Review."— Presentation transcript:

1 Linear Algebra Review

2 Chapter 0 - Review of linear Algebra
Objectives Basic definitions on matrices Matrix multiplications Addition and subtraction of matrices Computing the determinant of a matrix Scaling of a matrix Matrix transformation Transpose and Inverse of a matrix DOT and CROSS Products of vectors

3 What is a matrix? A matrix is a two dimensional array that stores the elements (numbers, or symbols representing numbers) in m rows and n columns. A matrix might be denoted by a letter such as A and is said to be m-by-n (m×n) in size. Here is an example: Note that indices start from 1 in MATLAB.

4 Example of a 4-by-4 matrix:
What is a matrix? Example of a 4-by-4 matrix: The 4-by-4 matrix on the right hand side can be created in MATLAB using: A = [ ; ; ; ] Note that indices start from 1 in MATLAB. Also each row is separated by a “;” and each member by a blank space. If you type the above on MATLAB command line you will get: A =

5 Multiplying two matrices
Let B and C be m-by-n and q-by-p matrices respectively. Here is what we can say about the product of these two: B * C is possible iff n = q C * B is possible iff p = m Thus, the product of two matrices is possible when the number of columns on the left matrix is the same as the number of rows on the right matrix. How do we multiply two matrices. We show this in an example: I am sure by going through this example you will figure out how the rows on the first matrix were multiplied by the columns of the second one, one-by-one. Note that we couldn’t multiply C by B, why?

6 Adding or Subtracting two matrices
To add or subtract two matrices, they must be exactly of the same type and size. Example (Addition) Example (Subtraction) In this case, it is possible to do B+C and C+B and they both produce the same result. However, B-C and C-B are possible but do not produce the same result.

7 Multiplying a matrix by a constant or Identity Matrix
When you multiply a matrix by a constant, all elements of the matrix will be multiplied by that constant. The is referred to as scaling. Example (const=4): The Identity matrix is a square matrix (number of rows and columns are the same), where the diagonal values of the matrix are all 1 and the rest of the elements are 0. When multiplied by another matrix of the same size, identity matrix produces the original matrix.

8 Computing the determinant of a matrix
Each square matrix of arbitrary size has a number called determinant of the matrix. This number is computed through a process. Let’s try a 2-by-2 matrix first: This is a bit more complicated when matrix is of larger size. Let’s try a 3-by-3 matrix. Similarly, for a 4-by-4 matrix, you will go through three steps: 1) Take the header of the first row, with corresponding 3-by-3 matrices underneath, 2) Process the 3-by-3 matrices by repeating the steps in the above example, 3) Compute the determinant of the 2-by-2 matrices and unfold them to find the final result.

9 Transpose and Inverse of a Matrix
The transpose of a matrix is the same matrix with rows and columns switched. The transpose of the A is: The inverse of a matrix, A-1, is the matrix that produced the unit matrix I when it is multiplied by the matrix itself. I = A-1* A. There are several ways to compute the inverse of a matrix. We will introduce the most common one here. Perhaps, we need to find out whether a matrix has an inverse (invertible). If a matrix is not invertible, it is singular. An n-by-n matrix A is invertible if there exists an n-by-n matrix C such that AC = CA = I, where I is the identity matrix.

10 Inverse of a Matrix How do we find the inverse of a matrix? See example below. We wish to compute A-1: First place the identity matrix of the same size on the right-hand-side of the original matrix. Then, work out through steps to move the identity matrix to the left-hand-side. Once that is accomplished, the matrix on the right-hand-side will be the inverse. Step1: we need to get ride of 4 on the first row. Thus, we will use: row1 = row1 – (.5) row2 Step2: we need to get ride of 6 on the second row. Thus, row2 = row2 + 6row1 Step3: The matrix on the left is almost ready. The next thing we need to do is to divide the each row by a number to produce the identity matrix on the left. Row1=row1*(-1), row2 = row2/8 As you notice the identity matrix has moved to the left-hand-side and thus the right-hand-side matrix is the inverse.

11 What is the angle between these two vectors?
DOT Product The DOT product of vector will be a scalar and can also be defined as: The DOT product of two orthogonal (vertical) vectors is 0. Example: v = 2i + 3j – 4k and u = 2i - 3j + 2k What is the angle between these two vectors? First we need to compute the magnitude (length) of each vector.

12 Example: v = 2i + 3j – 4k and u = 2i - 3j + 2k
CROSS Product The CROSS product can be defined as: Example: v = 2i + 3j – 4k and u = 2i - 3j + 2k Note: The result is a vector

13 Statistics Review

14 Chapter 0 - Review of Statistics
Objectives Computing the mean (average) Finding the median Computing the variance Computing standard deviation Probability and random numbers Probability distribution function Cumulative distribution function

15 Computing mean and median
The mean of a set of values is the weighted average of the possible values in that set. Basically sum of all values divided by the number of values. Sometimes this can be written as the sum shown on the right-hand-side. Where f denotes the number of occurrences of a particular value being observed in the set. The median is the point in the sequence where the set is divided into two equal parts each containing ½ of the values. Example: X = {2, 12, 4, 12, 7, 3, 5, 12, 4, 8, 2} Sorted X={2, 2, 3, 4, 4, 5, 7, 8, 12, 12, 12} The number in the middle of this set is 5, that is the median. What if we had an even number of values? What is the average? Values f (frequency) 2 3 1 4 5 7 8 12

16 Measure of Variation The mean and median do not describe the amount of dispersion or variation among the observed values. See examples below: All three have the same median and mean. The first measure of variance is range. Once again let’s consider X = {2, 12, 4, 12, 7, 3, 5, 12, 4, 8, 2}. Range defines the difference between the largest and the smallest values. Range = 12-2 = 10. The second measure of variation is the mean deviation, which is defined as:

17 Measure of Variation The most commonly used measure for the variation is sample variance referred to as variance. For the X = {2, 12, 4, 12, 7, 3, 5, 12, 4, 8, 2}, this will be: The standard deviation is an important measure deviation usually referred to as the error and is defined as:

18 MATLAB Examples Let the columns represent heart rate, weight and hours of exercise per week

19 Random numbers and probability
Probability of an event, xi, is the chance of observing that event when a large number of observations have been made. This is defined as: Where, Nx represents the number of times that that particular event have been observed and N represents the total number of observations. Of course, the sum of all probabilities must be 1, i.e., if you try all the possibilities, then you must observe all events. For example in the set: X = {2, 12, 4, 12, 7, 3, 5, 12, 4, 8, 2} Note: The sum of all these probabilities is 1: A random set is a set in which the probability of a variable appearing is the same as that of all other variables. Since we cannot create perfectly random values we use pseudo random generators to produce a set of values.

20 Probability Distribution and Cumulative Distribution
In the previous example we had: PDF CDF This is simply plotting the probabilities of each values as they are observed. Using this type of distribution we can easily tell which one of the values were seen most often This is the cumulative probabilities as we get to the next values. The final result is always 1. That is where all possible values are observed


Download ppt "Linear Algebra Review."

Similar presentations


Ads by Google