Zero Labs
Industry News / AI

Matrices — Mathematics of Perceptions

Source · Towards AI By Wuiii

From the publisher’s feed, collected in the ZeroLabs newsroom.

Matrices — Mathematics of PerceptionsNote: This article assumes you have read about matrices but didn’t understand its geometric meaning or significance or didn’t intuite about it. The article helps understand while revisiting your already read concepts.Spoiler alert! This is a very interesting topic. Perhaps, the most interesting fundamental thing in that is the beauty in thinking and intuiting of such great ideas. My approach while unvieling the beauty is that, let us first consider there is no such thing as matrix. Then, what we do is we will slowly (re-)discover it. I hope this will be an interesting way.Consider that, you are calling your friend Rene to get apples from your another friend Isaac. Rene asks you Where is Isaac? You respond with something like: Well, you can find him if you go rightwards. Rene is obedient he listens to you and goes to his rightwards and doesn’t find him. He instead misses him.You, Isaac, Rene MapAs we can totally see that there is a problem in our general approach to just tell something is right or left or any direction. This problem can be thought as the way you percieve the word and its routes is different from the way Rene percieves. And these different perceptions over the same thing is causing problems.Earlier, or the most normal way we solve this problem is let them both agree on a frame of reference. Let us give some framework called North-West-East-South to each of them. And, whenever they speak, they must follow the framework. In this way, they can work together. Well, this is definetly a solution and that is the general thing we do.How do we represent this framework and explain it to them for practical use? What exactly is North/West/East/South to each of them? Let’s say we tell each of them what are these directions in their own perspective. This solves the problem in different perceptions of directions for each of them. Now, they can follow the commonly thought framework to know directions.Lets now continue our story, now again on another day you call Rene and tell to meet Isaac to get apple. Now, you clearly mention Rene to go north to find him. Rene thinks that, its just a few minutes of ride (as told by you) and he goes towards north. But, in realty he feels that he traveled quite a lot than you told it took him an hour almost. And as you investigate about this you realize that the distance with which you and Rene is traveling in a unit time is different to each other. So, now you have to even make some standardized framework about how much is one step (distance in unit time assuming a constant speed.)Concluding from what we have learnt. We had require direction and also magnitude of each step in our framework. Does this sound familiar? Quantities that have magnitude and direction are called vectors. So, a better solution for this problem would be vector based framework. In other words, we would use vectors to somehow solve this. This is an intuitive idea before proceeding to the next section.From our understanding till now, if you want to tell Rene about the position of Isaac, you need a ordered collection of information. The ordered collection (Lets call it Ord. Collection) contains two very important vectors. These vectors act as translators between the shared framework and Rene. The first vector tells What direction is east? according to Rene’s perspective. While, the second vector tells what direction is north according to Rene’s perspective. Recall that again, vector doesn’t just say about direction, it also says about step length/distance (per unit time).These ord. collection of vectors which we are talking about are called spanning vectors. Why? Because they teach us how to span/measure a perception of space. Now, lets rethink the whole thing so that we get a clear idea on this. In our example, we had two problems. Firstly, people have their own perception of space so their coordinate plane (or way of measuring) and the axes itself might be in different direction. The other possibility is their one unit of distance is different that the one unit of distance according to others perception. To solve this, we had given each of them ord. collection of vectors (to get to a shared framework). These vectors tell how much one unit is in each axis by their magnitude and what direction the axis is.Now, each point in space, can be said as a combination of these vectors. We could say something like these many X axis unit vectors and these many Y axis unit vectors gives this point. This is why I say that these vectors are kinda rules which defines a perception of space. Example: A perception of space would be something like a gaint space where our 1 unit can be actually 10 units in normal cartesian space. Or a space in which the axis itself are tilted.A ordered sub-collection (Lets call it, ord. sub-collection) of those spanning vectors are called basis vectors. Basis vectors are a little bit special vectors. Why? Because they are those spanning vectors which are unique in a way that the other spanning vectors even if scaled and combined in various proportions can’t make up these vectors.In this section we will study how we represent the above ideas more mathematically and try to guess why do we do that in a certain way. Starting with vectors, lets consider our general notation inspired by our physics classes on how we refer to a point (3,4) using a position vector as described below.Eq. 1: Exemplary vector representation in high school physicsSuppose, we have huge dimentions. How should we represent now? Example a point (2, 3, 5, 2, 1, 3) or something like (4, 2, 7, 2, 3)? So we represent this using an altered notation. The below image shows you an altered version of representation of a generalized point in nD space:Eq. 2: Column position vector notation for points in nD spaceNow, the understanding of us so far is the space is made using some vectors which help to reach various points in space. These vectors make up the whole space. The view is described in the image below.A space view constructed by 2 vectors v1 and v2The above 2D space perspective is constructed by v1 and v2 vectors. Do not be surprised if you see v1 and v2 tilted (not orthogonal) and constructing space as shown in image below.Space by v1 & v2 when they are not orthogonal vectorsAlso recall that, any point in space which is located by the position vector of the point uses a scalled version of small vectors to reach that point. If we have a ordered collection of 2 vectors u and v. Then the point (4, 1) is represented by 4u + 1v. This can also be said as, the vector 4u + 1v is a linear combination of u and v. This is described in the image below.An example for linear combination of vectors u & v.Just for you to get good idea or as a information for comparision, our normal cartesian plane which we were thought in school is also made up of 2 basic vectors which are unit vector in x and unit vector in y (talking about 2D). In physics textbook, when you learnt about i and j components (as mentioned in Eq. 1) these i and j are actually these basic unit vectors.Eq. 3: i and j values in 2D space.I had mentioned earlier that we represent a perception of space (or way of measuring space) using a ordered collection of vectors. I would like to be more precise as you have reached till here. Lets ask Why should it be ordered? They have to be ordered because when they communicate each other about shared framework. Each axis’s basis vector of their space should map to the corresponding axis’s basis vector belonging to framework’s perspective of space. These ordered collection of vectors are represented by a matrix where each column of the vector is a spanning vector in space. In the below image you can see the representation.This is the identity matrix as we know. It represents our normal ideal space rules telling about its basis vectors or most basic vectors using which the whole 2D space is constructed. Lets try with other basis vectors.Representation of matrix AThe representation of that space of matrix A (in red) is shown below in comparision with original space (in blue). Here, notice the coordinates of each of the red vectors.Transformation of space by A in Identity matrix’s (blue) view.Also notice that in Red’s perspective if we tilt this, how the original space (in blue) looks.Transformation of space by A in A’s own (red) view.If we plot a point (2, 1) in the space of matrix A, then, as you can observe in the below figure, the same point is (2, -1) which is different to you in our normal space.Comparision of points in A’s space and Identity Matrix/Normal space.Matrix can also be thought of something which linearly transforms space. Because when applied to any position vector (x, y) of space what any matrix does is that it linearly upscales or downscales it. As (x, y) is an arbitary point, for all values of (x, y) the effect will be on whole space. Thus, whole space expands or shrings or rotates in this operation. This is called as linear transformation as linear scalling is involved. The below are equations to justify.In this interpretation, we have a very interesting thing too. That is, a transformation (matrix) which reverses back previous transformation is called the inverse of previous transformation aka inverse matrix. The inverse matrix transformation of A in above example is as described below.Transformation of space by inverse matrix of AThis is the reason when applying when you linearly transform a space using a matrix and then use its inverse matrix to linearly transform space then you get back the previous space.Here, M is a matrix.Now lets give some happy ending to our initial story on how they solve this problem. Lets consider the shared framework matrix as F. The perception or the way they measure direction and step length (their vectors) is Y and R for you and Rene respectively. The message which is a vector transfered from you to Rene is represented by ‘y’ whereas the message vector transfrered from Rene to you (to confirm maybe) is represented by ‘r’.Communication between you and ReneFirstly, what you do is you remove your perception of seeing things (Y inverse) and tell what the vector is in the perception of framework (matrix F). Using this perception you communicate ‘y’ to Rene.Rene knows that you have applied the framework. He decodes what is according to his perception by first removing the perception of F (F inverse matrix) and applying his perception (applying R matrix).After he understands what you are saying (vector: direction and step length/magnitude). He might respond similarly to you with message ‘r’ by first removing his perception (R inverse matrix) and then thinking of it in frameworks perception (applying F matrix).Similarly, the decoding happens and the process continues.But, does it really work? Yes it works. Why? Guess in the comments :)ConclusionIt was definetly a great time explaining you guys. This is also my first medium article which I am writing. The knowledge was earned out of experiences from various domains and understanding. Even read FAQs if you have time as clarity and even extra content is put in it. Thanking you if you reach here so far. There is much to write but, I guess I have taken a lot of your time. Thanking you again. :)Frequently Asked QuestionsHow are matrices connected to perception?When we use a matrix, it is giving a new way of measuring space because we are linearly transforming it and measuring. And the basis vectors in the space tell us what are the rules to percieve the space to get a new perception. This would mean, different ordered collection basis vectors or matrices would give different measurements of the same thing. This is I believe the same thing as perception. Because, people see same thing and achieve different outcomes about the same thing. Why? the perception they see is different. Also, each matrix when applied on space, transforms the whole space (each and every point in it). This is a new perception of our space.How are basis vectors different from spanning vectors?Any point in space could be reached with multiple paths each containing multiple vectors combined to make a resultant vector which reaches the final point. Different vectors of space which would act as a tool in reaching a point are called spanning vectors. These are kept as columns in matrix. However, there exists in matrix (or in ordered collection of spanning vectors for space) a ordered sub-collection of vectors which cannot be formed via a linear combination of other spanning vectors. These special kind of vectors in the ordered sub-collection are called basis vectors.What if inverse of a matrix doesn’t exist?In the cases, where inverse doesn’t exist the determinent is zero. The determinent of a matrix tells you about the area of the small parallelogram made by basis vectors in 2D. In 3D, it tells you about the volume covered via one 3D block of basis vectors. In nD it tells you about the nD volume covered by the nD block of basis vectors. Here, what happens is when a transformation results in reduction of dimention of a space, the information of the earlier full space is lost. Thus, as an axis is lost, the component in the general formula of volume becomes zero. Hence, turning whole determinant to zero (Note: determinant tells about signed volume or signed area of unit basis vectors block). As determinant is zero the matrix is inversible. Or in other words, as information is lost, the matrix cannot be reconstructed back to higher dimension.Matrices — Mathematics of Perceptions was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.