机器学习(Machine Learning)- 吴恩达(Andrew Ng) 学习笔记(三) Matrices and Vectors 矩阵和向量 Addition and Scalar Multiplication 加法和标量乘法运算 Matrix Vector Multiplication 矩阵和向量的乘法 Matrix Matrix Multiplication 矩阵和矩阵的乘法 Matrix Multiplication Properties 矩阵乘法的特性 Inverse and Transpose 矩阵的逆运算和转置运算

Linear Algebra review (optional) 线代复习(选学)

Matrix

  1. Definition: Rectangle array of numbers. 矩阵是矩形数字数组

  2. Dimension of matrix: number of rows ( imes) number of columns.

    矩阵的维度:行数 ( imes) 列数,如2 ( imes) 3的矩阵,4 ( imes) 2的矩阵…

  3. Matrix Element(entries if matrix): (A_{ij}) = "(i, j) entry" in the (i^{th}) row, (j^{th}) column.

Vector

  1. Definition: An n ( imes) 1 matrix. 向量是一个n ( imes) 1的矩阵
  2. Also called: n-dimensional vector. 也叫作n维向量
  3. Vector Element: (y_i = i^{th}) element.

Addition and Scalar Multiplication 加法和标量乘法运算

Matrix Addition

Scalar Multiplication

Combination of Operands

Matrix Vector Multiplication 矩阵和向量的乘法

Matrix Matrix Multiplication 矩阵和矩阵的乘法

House sizes:

[2104, 1416, 1534, 852]

Have 3 competing hypotheses:

  1. (h_{ heta}(x) = -40 + 0.25 imes x)
  2. (h_{ heta}(x) = 200 + 0.1 imes x)
  3. (h_{ heta}(x) = -150 + 0.4 imes x)

Matrix:

( left[ egin{matrix} 1 & 2104 \ 1 & 1416 \ 1 & 1534 \ 1 & 852 end{matrix} ight] ) ( imes) ( left[ egin{matrix} -40 & 200 & -150 \ 0.25 & 0.1 & 0.4 \ end{matrix} ight] ) = ( left[ egin{matrix} 486 & 410 & 692 \ 314 & 342 & 416 \ 344 & 353 & 464 \ 173 & 285 & 191 end{matrix} ight] )

Matrix Multiplication Properties 矩阵乘法的特性

不满足交换律:A ( imes) B ( eq) B ( imes) A (单位矩阵除外)

满足结合律:A ( imes) (B ( imes) C) = (A ( imes) B) ( imes) C

Inverse and Transpose 矩阵的逆运算和转置运算

Matrix inverse: 矩阵的逆

If A is an m ( imes) m matrix, and if it has an inverse, (AA^{-1} = A^{-1}A = E).

Matrix Transpose: 矩阵的转置

Let A be an m ( imes) n matrix, and let (B =) (A^T).

Then B is an n ( imes) m matrix, and (B_{ij} = A_{ji}).

Example:

(A =) ( left[ egin{matrix} 1 & 2 & 0 \ 3 & 5& 9 \ end{matrix} ight] ), $B = A^T = $ ( left[ egin{matrix} 1 & 3 \ 2 & 5 \ 0 & 9 \ end{matrix} ight] )