【Study Notes】Mathematics for Machine Learning: Linear Algebra (Week 3)

Introduction

This is a study note of the course Mathematics for Machine Learning: Linear Algebra on the coursera. In this part, we will learn what matrices is, and operations in matrices. We can make transformations by using mactrices, and find the inverse of a matrix. In addition, the determinants will be explaned in this section.

Matrix

How matrices transform space

Given a vector r = [ x y ] r=\begin{bmatrix}x\\y\end{bmatrix} r=[xy] , and a 2 × 2 2 \times 2 2×2 matrix A A A .
Start with A r = r ′ Ar = r' Ar=r
We know r = [ x y ] = x e 1 ^ + y e 2 ^ r = \begin{bmatrix}x\\y\end{bmatrix}=x\hat {e_1} +y\hat{e_2} r=[xy]=xe1^+ye2^
where e 1 ^ \hat {e_1} e1^ and e 2 ^ \hat{e_2} e2^ are basic vectors, that is e 1 ^ = [ 1 0 ] \hat {e_1}=\begin{bmatrix}1\\0\end{bmatrix} e1^=[10] and e 2 ^ = [ 0 1 ] \hat {e_2}=\begin{bmatrix}0\\1\end{bmatrix} e2^=[01].
Then, we get A r = A ( x e 1 ^ + y e 2 ^ ) = x A e 1 ^ + y A e 2 ^ \begin{aligned}Ar&=A(x\hat {e_1} +y\hat{e_2})\\ &=xA\hat {e_1} +yA\hat{e_2}\end{aligned} Ar=A(xe1^+ye2^)=xAe1^+yAe2^
So we have made a transformation by using matrix A A A. We change the basic vector e 1 ^ \hat {e_1} e1^ to A e 1 ^ A\hat {e_1} Ae1^, and e 2 ^ \hat {e_2} e2^ to A e 2 ^ A\hat {e_2} Ae2^.

If we assume matrix A = [ a b c d ] A = \begin{bmatrix}a &b\\c&d\end{bmatrix} A=[acbd].
We get A e 1 ^ = [ a b c d ] [ 1 0 ] = [ a c ] A\hat {e_1}= \begin{bmatrix}a &b\\c&d\end{bmatrix} \begin{bmatrix}1\\0\end{bmatrix}= \begin{bmatrix}a\\c\end{bmatrix} Ae1^=[acbd][10]=[ac], and A e 2 ^ = [ a b c d ] [ 0 1 ] = [ c d ] A\hat {e_2}= \begin{bmatrix}a &b\\c&d\end{bmatrix} \begin{bmatrix}0\\1\end{bmatrix}= \begin{bmatrix}c\\d\end{bmatrix} Ae2^=[acbd][01]=[cd].
Finally, we change the basis to the columns of matrix A A A.
Then, we can say the basis after changing are the columns of matrix A A A.

Types of matrix transformations

Stretching

The matrix associated with a stretch by a factor k k k along the x-axis is given by:
[ k 0 0 1 ] \begin{bmatrix}k &0\\0&1\end{bmatrix} [k001]
Similarly, a stretch by a factor k k k along is given by:
[ 1 0 0 k ] \begin{bmatrix}1 &0\\0&k\end{bmatrix} [100k]

Squeezing

If the two stretches above are combined with reciprocal values, then the transformation matrix represents a squeeze mapping:
[ k 0 0 1 / k ] \begin{bmatrix}k &0\\0&1/ k\end{bmatrix} [k001/k]
A square with sides parallel to axes is transformed to a rectangle that has the same area as the square. The reciprocal stretch and compression leave the area invariant.

Rotation

For rotation by an angle θ clockwise about the origin the functional form is x ′ = x cos ⁡ θ + y sin ⁡ θ x'=x\cos \theta +y\sin \theta x=xcosθ+ysinθ and y ′ = − x sin ⁡ θ + y cos ⁡ θ y'=-x\sin \theta +y\cos \theta y=xsinθ+ycosθ. Written in matrix form, this becomes:
[ cos ⁡ θ sin ⁡ θ − sin ⁡ θ cos ⁡ θ ] \begin{bmatrix}\cos\theta &\sin\theta\\-\sin\theta&\cos\theta\end{bmatrix} [cosθsinθsinθcosθ]
Similarly, for a rotation counterclockwise about the origin, the functional form is x ′ = x cos ⁡ θ − y sin ⁡ θ x'=x\cos \theta -y\sin \theta x=xcosθysinθ and y ′ = x sin ⁡ θ + y cos ⁡ θ y'=x\sin \theta +y\cos \theta y=xsinθ+ycosθ the matrix form is:
[ cos ⁡ θ − sin ⁡ θ sin ⁡ θ cos ⁡ θ ] \begin{bmatrix}\cos\theta &-\sin\theta\\\sin\theta&\cos\theta\end{bmatrix} [cosθsinθsinθcosθ]

Shearing

[ 1 k 0 1 ] \begin{bmatrix}1 &k\\0&1\end{bmatrix} [10k1]
or
[ 1 0 k 1 ] \begin{bmatrix}1 &0\\k&1\end{bmatrix} [1k01]

你可能感兴趣的:(【Study Notes】Mathematics for Machine Learning: Linear Algebra (Week 3))