Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,540 --> 00:00:04,250
Hello everyone and welcome to the lecture on matrix operations.
2
00:00:04,270 --> 00:00:09,120
Now that we learn how to create a matrix Let's go ahead and learn how to use functions and perform operations
3
00:00:09,120 --> 00:00:10,140
on that matrix.
4
00:00:10,320 --> 00:00:12,240
Let's jump to our studio.
5
00:00:12,240 --> 00:00:12,560
All right.
6
00:00:12,570 --> 00:00:14,450
So here are our studio.
7
00:00:14,550 --> 00:00:19,860
Make sure you've saved the code from the previous lecture or you can reference the notebook or notes
8
00:00:19,860 --> 00:00:25,410
for this lecture to go ahead and copy and paste this code which creates the stock matrix from the creating
9
00:00:25,410 --> 00:00:27,630
matrices lecture.
10
00:00:27,960 --> 00:00:30,830
Now that you have your stock matrix Let's go ahead and just run this.
11
00:00:30,840 --> 00:00:32,110
Make sure we have it.
12
00:00:32,190 --> 00:00:37,790
So we have our stock Matrix where the rows are the ticker symbols for Google and Microsoft stock and
13
00:00:37,790 --> 00:00:42,310
the columns represent some made up stock price for those days of the week.
14
00:00:42,330 --> 00:00:47,690
Let's go ahead and show how we can perform just some basic functions across columns and rows.
15
00:00:47,730 --> 00:00:53,640
So imagine you wanted to get the total sum of these stocks across the columns.
16
00:00:53,640 --> 00:00:56,520
You can use call some to do that.
17
00:00:56,610 --> 00:01:02,910
So that in through the consul and raise it up a bit since we already have these values in our environment
18
00:01:03,000 --> 00:01:07,170
I can go ahead and use call some's.
19
00:01:07,170 --> 00:01:14,640
Notice that the ES capitalized and then I can just pass in my stock matrix and I'm using our CDs kind
20
00:01:14,640 --> 00:01:20,340
of autocomplete here and that's going to sum the columns together.
21
00:01:20,370 --> 00:01:26,190
So I have the value sum for Monday Tuesday Wednesday Thursday Friday so you can imagine this is useful
22
00:01:26,190 --> 00:01:32,010
if you happen to have one stock of Google on one stock of Microsoft and you wanted to get your total
23
00:01:32,010 --> 00:01:39,370
portfolio value for each of those days if you wanted to get the rose some's even though it doesn't make
24
00:01:39,440 --> 00:01:41,460
too much sense for the data we have.
25
00:01:41,940 --> 00:01:50,190
You can do row sums as well and that will come across those rows so it's good to sum all those days
26
00:01:50,190 --> 00:01:53,980
together and across all those stock prices.
27
00:01:54,180 --> 00:01:59,500
OK so we have column some's and Rose sums and we can also do mathematical operations.
28
00:01:59,700 --> 00:02:04,550
So for example I could say row means.
29
00:02:04,890 --> 00:02:13,290
And then again just puts stock matrix and that will give me the mean value for those ROEs across both
30
00:02:13,290 --> 00:02:15,050
Google stock and Microsoft stock.
31
00:02:15,150 --> 00:02:20,460
So this is making a little more sense for the data we have because we can get the mean or average value
32
00:02:20,460 --> 00:02:24,990
for the week of Google stock and Microsoft's stock.
33
00:02:24,990 --> 00:02:30,900
And similarly you can actually use call means to do the same operation just across the columns.
34
00:02:30,900 --> 00:02:36,750
So something to note here is that there's a reference link in the notes for this lecture where it's
35
00:02:36,750 --> 00:02:40,380
going to have a reference to all the available functions for Matrix.
36
00:02:40,530 --> 00:02:44,430
And you'll notice that a lot of these functions are actually very similar to the built in functions
37
00:02:44,430 --> 00:02:49,290
for vectors except they just specify whether you're performing the action across the rows or across
38
00:02:49,290 --> 00:02:50,900
the columns.
39
00:02:50,910 --> 00:02:51,460
All right.
40
00:02:51,540 --> 00:02:55,070
So let's go ahead and see how we can add columns and rows to a matrix.
41
00:02:55,080 --> 00:03:00,810
We can use the C bind function to buy the new column and the our bind to bind a new row.
42
00:03:01,320 --> 00:03:07,330
Let's go ahead and console and create a new vector or call f b.
43
00:03:07,410 --> 00:03:13,750
And this is just going to be some made up Facebook stock values for the five days.
44
00:03:13,770 --> 00:03:16,470
Let's say there's a jump.
45
00:03:16,470 --> 00:03:16,730
All right.
46
00:03:16,740 --> 00:03:18,890
So I have my vector F. B.
47
00:03:18,990 --> 00:03:26,580
Now let's say I want to bind this to my original stock Matrix I can go ahead and make a new variable
48
00:03:26,580 --> 00:03:26,760
.
49
00:03:26,910 --> 00:03:35,580
I'll call it tech stocks and I'm going to have it be equal to our binds in our bine is going to take
50
00:03:35,580 --> 00:03:41,850
in our original matrix as the first arguments and the next argument is going to be what else we want
51
00:03:41,850 --> 00:03:48,120
to buy into it then in this case I want to bind SB to it and notice that I'm using our bind because
52
00:03:48,120 --> 00:03:50,610
I want to bind it as a new row.
53
00:03:51,440 --> 00:03:53,250
And so now if I check out tech stocks
54
00:03:55,950 --> 00:04:02,750
I get this nice output with Google Microsoft and our new Vektor Facebook stock binded as a new row.
55
00:04:03,870 --> 00:04:10,480
Something to note here is that the variable name F B was actually used as the new Wrone.
56
00:04:10,590 --> 00:04:13,250
So that's a useful feature to keep in mind.
57
00:04:13,260 --> 00:04:17,670
Let's go ahead and see how we can add a new column to our matrix to do this.
58
00:04:17,670 --> 00:04:23,250
I want to go ahead and make a variable called a Viji and I'm going to have that be equal to the row
59
00:04:23,250 --> 00:04:28,300
means of the stock matrix.
60
00:04:28,710 --> 00:04:32,350
Actually the tech stocks matrix since we added SB to it.
61
00:04:33,210 --> 00:04:38,550
So we have this average and that's the average weekly average of all those stocks.
62
00:04:38,550 --> 00:04:41,780
Let's go ahead and buying that as a new column next to Friday.
63
00:04:41,950 --> 00:04:47,700
So we'll have the prices for each week of the day Monday Tuesday Wednesday and then finally we'll have
64
00:04:47,730 --> 00:04:51,080
a column consisting of the average price for that week.
65
00:04:51,300 --> 00:04:54,510
So I'm going to go ahead and say tech stocks
66
00:04:57,440 --> 00:05:04,770
see binds which stands for Columbines and I'm going to go ahead and say tech stocks and then pasan that
67
00:05:04,860 --> 00:05:06,950
average factor.
68
00:05:07,590 --> 00:05:12,630
So if you go ahead and clear this and check out what tech stocks is equal to no notice we have that
69
00:05:12,630 --> 00:05:13,940
nice average.
70
00:05:14,250 --> 00:05:15,750
So that's it for this lecture.
71
00:05:15,750 --> 00:05:21,300
Later on we're going to learn even more useful features of matrices in our thanks everyone and I'll
72
00:05:21,300 --> 00:05:22,200
see you at the next lecture
7752
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.