본문 바로가기

BITS

[Machine Learning by Stanford] Linear Algebra Review - Inverse and Transpose

This is a brief summary of ML course provided by Andrew Ng and Stanford in Coursera.

You can find the lecture video and additional materials in 

https://www.coursera.org/learn/machine-learning/home/welcome

 

Coursera | Online Courses From Top Universities. Join for Free

1000+ courses from schools like Stanford and Yale - no application required. Build career skills in data science, computer science, business, and more.

www.coursera.org

Special matrix operations, called the matrix inverse and matrix transpose operation.

 

Say that 1 is a identity for scalars, if the product of some number a and b gives the identity, 1, we call this number b is an inverse of a. But note that not all numbers have an inverse. (e.g., 0 doesn't have an inverse)

 

Matrix Inverse:

If A is an m x m (square) matrix, and if it has an inverse, $A(A^{-I}) = (A^{-I})A = I $

$A = \left[\begin{array} {rrr} 0 & 0 \\ 0 & 0 \end{array}\right] $ does not have an inverse. 

* matrices that don't have an inverse are "singular" or "degenerate"

 

e.g., $\left[\begin{array} {rrr} 3 & 4 \\ 2 & 16 \end{array}\right] $ $\left[\begin{array} {rrr} 0.4 & -0.1 \\ -0.05 & 0.075 \end{array}\right] $ = $\left[\begin{array} {rrr} 1 & 0 \\ 0 & 1 \end{array}\right] $

 

Matrix Transpose

Let A be an m x n matrix, and let B = $A^T$.

Then B is an n x m matrix, and $B_{ij} = A_{ji}.

Take 45 degrees and mirroring(flipping)

 

$A = \left[\begin{array} {rrr} 1 & 2 & 0 \\ 3 & 5 & 9 \end{array}\right] $, $A^T = \left[\begin{array} {rrr} 1 & 3 \\ 2 & 5 \\ 0 & 9\end{array}\right] $

e.g., $B_{12} = A_{21} = 2, B_{32} = A_{23} = 9$

 

Quiz: What is $\left[\begin{array} {rrr} 0 & 3 \\ 1 & 4 \end{array}\right] ^ T$?

 

Answer: $\left[\begin{array} {rrr} 0 & 1 \\ 3 & 4 \end{array}\right] ^ T$

 

Lecturer's Note

The inverse of a matrix A is denoted $A^{-I}$. Multiplying by the inverse results in the identity matrix.

A non square matrix does not have an inverse matrix. Matrices that don't have an inverse are singular or degenerate.

 

We can compute inverses of matrices in octave with the pinv(A) function and in Matlab with the inv(A) function.

 

The transposition of a matrix is like rotating the matrix 90° in clockwise direction and then reversing it. We can compute transposition of matrices in matlab with the transpose(A) function or A':

 

$A = \left[\begin{array} {rrr} a & b \\ c & d \\ e & f\end{array}\right] $ $A^T = \left[\begin{array} {rrr} a & c & e \\ b & d & f \end{array}\right] $

In other words:

$A_{ij} = A_{ji}^T$

 

% Initialize matrix A 
A = [1,2,0;0,5,6;7,0,9]

% Transpose A 
A_trans = A' 

% Take the inverse of A 
A_inv = inv(A)

% What is A^(-1)*A? 
A_invA = inv(A)*A