0% found this document useful (0 votes)
15 views

Data Analysis - Matrix

Uploaded by

joeljoseph2901
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Data Analysis - Matrix

Uploaded by

joeljoseph2901
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Data Analysis – Matrix

A matrix is a rectangular arrangement of numbers. The numbers are


arranged in tabular form as rows and columns.
For Example:

[ ]
15 19
A= 11 17
51 20

The knowledge of matrices is necessary in all branches of mathematics.


It is one of the most powerful tools in Math. When compared to other
methods, it helps to simplify calculations.
Like, for example, Consider the Following Data:
Oranges Apples
Ganga 12 5
Hemant 10 7
Gargi 5 2
This data can also be written in matrix form just as the Matrix given
above, where row 1, 2 and 3 represents Ganga, Hemant and Gargi
respectively and the columns 1 and 2 represents Oranges and Apples
respectively.

[ ]
12 5
A= 10 7
5 2

It can also be written in such a way that the Rows Represent the Fruits,
and the Columns represent the People. Like:
A= [ 125 10 5
7 2 ]

The name of a matrix is written in capital letters.


Order of Matrices:
The order of a matrix typically represents the number of rows and
columns a matrix has. It is written as “m x n” where m represents the
number of rows and n represents the number of columns.
Each element is represented as ‘aij ’where ‘i’ represents rows and ‘j’
represents columns.
Therefore, the Matrices given in the previous example is a 3x2 matrix
and a 2x3 matrix.

Types of Matrices:
There are mainly 8 types of Matrices:
1. Row Matrix
A matrix that only has one row is known as a Row Matrix.
E.g. [ 1 3 5]

2. Column Matrix
A matrix which contains only one column is known as a Column
Matrix.

[]
2
E.g. 4
6

3. Square Matrix
A matrix having equal number of rows and columns is known as Square
Matrix.
E.g. [ 13 46]
4. Diagonal Matrix
A matrix having all elements as zeros except for its leading diagonal is
known as a Diagonal Matrix.

[ ]
13 0 0
E.g. 0 1 0
0 0 41

5. Scalar Matrix
A Matrix where all the diagonal elements in the leading diagonal has the
same value while others are zero is known as a Scalar Matrix.

[ ]
4 0 0
E.g. 0 4 0
0 0 4

6. Unit Matrix
A Matrix where all the elements in the leading diagonal are 1 and the
rest are zero is known as a Unit Matrix.

[ ]
1 0 0
E.g. 0 1 0
0 0 1

7. Upper Triangular Matrix


A square matrix where all the elements below the diagonal are zero is
known as an Upper Triangular Matrix.

[ ]
16 40 6
E.g. 0 15 7
0 0 16

8. Lower Triangular Matrix


A Matrix where all the elements above the diagonal are zeros is known
as a Lower Triagonal Matrix.
[ ]
1 0 0
E.g. 1 6 0
4 8 9

Applications Of Matrices in AI:-


There are a wide range of Applications of Matrices in our current
Society.
Some of them are:
1. Sales Forecasting & Price Prediction
2. Image Processing: Digital images can represent using matrices. For
example, in the given figure, a matrix is used in order to create a
image. The matrix is created in binary. A ‘0’ Represents it is filled
in black or is blank and a ‘1’ denotes that the pixel is white.

3. Recommender Systems: Matrices are used in order to relate


between users and the purchased or viewed items.
4. Natural Language Processing (NLP)
5. Computer Vision: Matrices are extensively used in image
processing tasks, such as object detection, segmentation and
classification. Techniques like convolution Neural Network
(CNNs) employ matrices to represent image data and perform
operations like convolution and pooling
Operations On Matrices
1. Addition of Matrices
The sum of 2 matrices is a matrix obtained by adding the corresponding
elements in the given Matrices. We should also note that the 2 Matrices
should be of the same order.
A= [ ac bd ] B= [ ge hf ] A+B = [ (a+e ) (b+ f )
(c + g) (d +h) ]
E.g.
A= [ ]
1 3
3 4 B= [ ]
2 5
8 9 A+B = [ 3 8
11 13 ]

2. Difference of Matrices
The Difference of 2 matrices is taken in the same manner of their sum.
The elements of the resultant matrix are taken by subtracting their
corresponding values. Just like addition, the 2 matrices should be of the
same order.
A= [ ac bd ] B= [ ge hf ] A-B = [ (a−e) (b−f )
( c−g) (d−h) ]
E.g.
A= [ 1016 1311 ] B= [ 26 58] A-B = [ 108 83 ]

3. Transpose of a Matrix
The transpose of a matrix is obtained by interchanging the rows and
columns of a matrix. It is denoted by AT .
A= [ ac bd ] AT = [ ab cd ]
E.g.
A= [ 13 24] AT = [ 12 34]

4. Multiplication By A Scalar
When we multiply a Matrix by a scalar, we simply multiply all the
elements in the Matrix with the given Scalar.
A= [ ac bd ] A . x=
[ ac .. xx b.x
d.x ]
E.g.
A= [ 13 24] A*2 = [ 26 48 ]
5. Multiplication of Matrices
To multiply 2 given matrices, The number of columns in the first matrix
should be equal to the number of rows in the second matrix. To get the
product of a matrix we multiply the row of the first matrix and multiply
it with the column of the second matrix and take their sum. To get its
first element, We Add the product of the first row of A and first Column
of B. For its second element, we add the product of the second row of A
and second column of B
The resultant Matrix will be of the order: -
(Number of Rows of A) x (Number of Rows of B)
For example, for the given Matrices,
Order of A = 1x2
B = 2x2
AxB = 1x2
A = [1 2] B= [ 13 24]
A∗B=[ ( 1∗1 )+ ( 2∗3 ) ( 1∗2 ) + ( 2∗4 ) ] =[ 8 10 ]
Order of C = 3x2
D = 2x3
CxD = 3x3

[ ]
1 2
C= 3 4 D=
5 6
1 2 3
4 5 6 [ ]

[ ]
(1∗1 ) + ( 2∗4 ) ( 1∗2 )+ ( 2∗5 ) ( 1∗3 ) + ( 2∗6 )
C∗D= ( 3∗1 )+ ( 4∗4 ) ( 3∗2 ) + ( 4∗5 ) (3∗3 )+ ( 4∗6 )
( 5∗1 ) + ( 6∗4 ) ( 5∗2 )+ ( 6∗5 ) ( 5∗3 )+ ( 6∗6 )

[ ]
9 12 15
¿ 19 26 33
29 40 51

6. Determinants of Matrices
The Determinant of a matrix is a scalar value that can be computed from
the elements of the matrix and provides important information about the
matrix. It is denoted by either det(A) or |A|. The determinant is defined
for square matrices only.

The Determinant of a 1x1 Matrix is the element in the matrix itself


A=[ 2 ]| A|=2
The Determinant of a 2x2 matrix can be calculated by using a simple
formula
A=
[ ac bd ]|A|=( a∗d )− ( b∗c )
E.g.
A=
[ 13 24 ]|A|=4−6=−2

For a 3x3 Matrix, the determinant can be found using the following
formula:

[ ]
a b c
A= d e f | A|=a ( e . i−h . f ) −b ( d .i−g . f )+ c ( d . h−g . e )
g h i

E.g.

[ ]
1 2 3
A= 2 4 3 | A|=1 ( 8−9 )−2 ( 4−3 )+3 ( 6−4 )¿−1−2+6¿ 3
1 3 2

7. Inverse of a Matrix
The inverse of a matrix is matrix which when multiplied by the original
matrix gives us an identity matrix.
It is like the reciprocal of a number. When we multiply the number by
its reciprocal, we get 1. Just like that when we multiply a matrix with its
inverse, we get an identity matrix.

2x2 Matrix:
To find the inverse of a 2x2 Matrix, First find its adjoin and then divide
the adjoin with the determinant:
−1 1
i.e. A =
| A|
∗Adjoin

A=
[ ac bd ] Adjoin=[−cd −ba ] A −1
=
1
| A|

[d −b
−c a ]
E.g.
A=
[ 13 24 ]
| A|=4−6=−2

Adjoin=
[−34 −21 ]
[ ]
−2 1
−1 1
A = ∗
4 −2
−2 −3 1
= 3 −1
2 2
[ ]

3x3 Matrix:
Finding the Inverse of a 3x3 Matrix is a bit more difficult than a 2x2
Matrix. It involves Various steps, Such as:
1. Finding Determinant
2. Finding The Co-factor
3. Finding the Adjoin and,
4. Dividing the Adjoin with the Determinant
−1 1
i.e. A =
| A|
∗Adjoin

To find the Co-factor, we multiply the elements just like we do for


determinant but with some little changes. Then we change the sign of
the resultant matrix in an alternating manner.

[ ]
a b c
Let A= d e f
g h i
[ ]
+ ( e . i−f . h ) −( d .i−f . g ) + ( d . h−e . g )
Co−factor= −( b . i−c . h ) + ( a . i−c . g ) − ( a . h−b . g )
+ ( a . e−b . d ) − ( a . f −c . d ) + ( b . f −c . e )

To find the Adjoin, We Transpose the cofactor.

[ ]
+ ( e .i−f . h ) −( b . i−c .h ) + ( a . e−b .d )
Adjoin ¿ −( d . i−f . g ) + ( a .i−c . g ) − ( a . f −c . d )
+ ( d . h−e . g ) − ( a . h−b . g ) + ( b . f −c . e )

Thereby, The Inverse of the Matrix is:

[ ]
+ ( e . i−f . h ) −( b . i−c . h ) + ( a . e−b . d )
−1 1
A = ∗ −( d . i−f . g ) + ( a .i−c . g ) −( a . f −c . d )
| A|
+ ( d . h−e . g ) − ( a . h−b . g ) + ( b . f −c . e )

For Example:

[ ]
1 2 3
A= 1 6 4
1 5 3

Determinant = 1 ( 18−20 )−2 ( 3−4 ) +3 ( 5−6 )=−2+ 2−3=−3

[ ]
+(18−20) −(3−4) +(5−6)
Co-Factor = −(6−15) +(3−3) −(5−2)
+(8−18) −(4−3) +(6−2)

[ ]
−2 1 −1
= 9 0 −3
−10 −1 4

[ ]
−2 9 −10
Adjoin = 1 0 −1
−1 −3 4
[ ]
2 −10
3
3 3

[ ]
−2/−3 9/3 −10 /3
1 −1
A-1 = 1/3 0/3 −1 /3 =
3
0
3
−1/3 −3/3 4 /3
−1 4
−1
3 3

You might also like