字幕列表 影片播放 列印英文字幕 hi and welcome back to our for statistics and data science, right? Last time we talked about's upsetting matrices, we used square bracket to extract elements by roll and column index blank spaces to call all elements in a dimension. And we called elements by column or row name. In this lesson, we will talk about matrix arithmetic, which I expect will remind you a lot of doing arithmetic with vectors. It should be nice and easy and quick. All right. Matrices are just Victor's older brothers. Okay, this means that they share a lot of their properties. Do you remember the mechanics of Victor Operations? Well, they happen an element twice manner. This holds true for matrices, too. Let's try scaling a matrix first. I will super quickly create a matrix with the box office data for a new movie franchise. We're stepping away from Hardy part of her a little bit matrix with the matrices grosses in the U. S. And Worldwide. Great. We have a simple three by two matrix telling us how the movies from The Matrix franchise fares on U. S. Soil and worldwide. That's it. We're all set to jump right into the calculations. notice that the figures in her matrix are in millions in U. S. Dollars. Well, what if I wanted to convert the millions into billions, for example? Because I have other data I want to compare this to, and that data is in billions. Well, in this case, I can use the scaler Multiplication scaler operations comprise multiplying or dividing an entire stricture by a single number. In this case, because I want the data in billions, I will divide my matrix by 1000 and get the desired result like this. See, the operation happened element by element, just like it did with Victor's. Fantastic. So what if I wanted to know how much each movie made after we subtract the money that went into producing the movie? Of course, the movies had different budgets, but their average is $121 million to find out the margin for the matrix movies, we just need to subscript 121 from the Matrix. Don't, Matt. And there you have it noticed that the command was again executed on element by element basis. Okay, so this holds true for all arithmetic operations. All right, but what about the more interesting stuff. Like matrix by matrix arithmetic. Well, those are also governed by the same rules. Everything will happen element wise, for example, if we take the margin calculation with it before. But this time I decided to use the real budgets for each movie instead of their average. We can create another to buy treat matrix with the information and substructure did from matrix. Don't Matt like this. And as before, the operation is happening. Cell by cell. Okay, so did you notice how we made the budget matrix just now? We passed three values one for each row and asked or to create two columns because the victor we passed was only of length three. And we're asking our for a matrix that has six values, or is three by two, are recycled the vector and created it for us. Repeating the three values twice. To be very honest, we didn't need to do that because our will recycle, even if we had simply subtracted a vector with the values 6350 and 100 and 50 from the matrix. Stop, Matt Matrix. Let's try it out. Yeah, awesome. The result we get is identical with the one before because our recognizes the victor and the Matrix as being of different sizes and does whatever it can to rectify this for the operation at hand. In other words, it recycles fantastic. Let's move on to matrix multiplication. If you have been paying attention to everything we've said so far, it will be painfully obvious to you that when you multiply two matrices together, the operations who happen how element by element Good. Let's have a quick look. I will multiply the box office gross for the franchise by three by two matrix storing the numbers from 1 to 6. It works just like expected. If you are a linear algebra enthusiast, however, you may be hoping that matrix multiplication happens the way traditional matrix multiplication is supposed to happen. If this is what you're after, you just have to ask nicely in Their multiplication happens when you use this operator and out there multiplication. When you use this one, don't forget to transpose, though we did this with the T function, remember? Of course, if you truly are a linear algebra enthusiast, that's probably the first thing that came to mind, didn't it? Okay, I won't finish the lesson on this note. And next time we'll switch to focus a little bit too more mathematically inclined to matrix operations like finding column and row sums averaging and so on form or videos like this one, please subscribe.