Hello All, This blog is about my first use case of linear algebra with coding.
Use of Rank of Matrix:
By definition, rank refers to the number of linearly independent vectors.
Now the question arises what is the use of this in programming
Let us take an example data set
We can see that
HRA is 10% of the salary
DA is 5% of the salary So instead of storing the records of each employee Salary, HRA, DA, we can simply store one of them and calculate the others as and when needed
Here Comes the role of Rank of a matrix The rank for this matrix is 1 which means that only 1 Column is Linearly independent. It also means that the other columns can be calculated from the one column(let's take salary) selected
A=matrix(c(50000,5000,2500,70000,7000,3500,80000,8000,4000),3,3,byrow =TRUE )
print(A)
library(pracma)
#Rank
print(Rank(A))
Output
[,1] [,2] [,3]
[1,] 50000 5000 2500
[2,] 70000 7000 3500
[3,] 80000 8000 4000
[1] 1 (Rank of the matrix)
Finding relationship of the columns:
20 x b1 + 2 x b2 + b3
We have come up with a relationship : 20 x salary =2 x HRA = DA
Now let's understand the use of the same Every record of employee has 3 fields and let's say we have 1000 records of employee 3x1000=3000 units of storage required. And for the same, if we use the above method we require (1x1000+ 3(for the relation))=1003 units of storage'
This was a simple example where we can find such linear relationships, but these concepts help us find all kinds of such useful relationships.
Thank you.