1 00:00:00,220 --> 00:00:01,128 Now that you know how to load 2 00:00:01,128 --> 00:00:03,062 and save data in Octave, put 3 00:00:03,062 --> 00:00:04,743 your data into matrices and so 4 00:00:04,743 --> 00:00:06,301 on. In this video I'd like 5 00:00:06,301 --> 00:00:08,252 to show you how to do computational 6 00:00:08,252 --> 00:00:10,343 operations on data and 7 00:00:10,343 --> 00:00:12,296 later on we'll be using this 8 00:00:12,320 --> 00:00:16,860 sorts of computation operations to implement our learning algorithms. 9 00:00:16,860 --> 00:00:19,360 Let's get started. 10 00:00:19,610 --> 00:00:21,031 Here's my Octave window. 11 00:00:21,031 --> 00:00:22,737 Let me just quickly initialize some 12 00:00:22,737 --> 00:00:24,939 variables to use 13 00:00:24,940 --> 00:00:26,679 for examples and set A 14 00:00:26,679 --> 00:00:29,185 to be a 3 by 2 matrix. 15 00:00:29,820 --> 00:00:31,495 and set B to a 16 00:00:31,510 --> 00:00:33,319 3 by 2 matrix and let's 17 00:00:33,330 --> 00:00:35,106 set C to a 18 00:00:35,120 --> 00:00:38,419 2 by 2 matrix, like so. 19 00:00:39,150 --> 00:00:41,948 Now, let's say I want to multiply 2 of my matrices. 20 00:00:41,960 --> 00:00:44,121 So, let's say I wanna compute AxC. 21 00:00:44,121 --> 00:00:45,713 I just type AxC. 22 00:00:45,740 --> 00:00:48,848 So, it's a 3 by 2 matrix times a 2 by 2 matrix. 23 00:00:48,860 --> 00:00:52,135 This gives me this 3 by 2 matrix. 24 00:00:52,160 --> 00:00:53,736 You can also do elements wise 25 00:00:53,740 --> 00:00:56,472 operations and do A.xB 26 00:00:56,500 --> 00:00:57,615 and what this would do is 27 00:00:57,615 --> 00:00:59,138 they'll take each elements of A 28 00:00:59,138 --> 00:01:00,584 and multiply it by 29 00:01:00,590 --> 00:01:02,558 the corresponding elements of B. 30 00:01:02,560 --> 00:01:06,390 So, that's A, that's B, that's A.xB. 31 00:01:06,700 --> 00:01:09,412 So, for example, the first element 32 00:01:09,420 --> 00:01:10,940 gives 1 times 11 which gives 11. 33 00:01:10,950 --> 00:01:14,045 The second element gives 34 00:01:14,045 --> 00:01:16,752 2 x 12 which gives 24 and so on. 35 00:01:16,760 --> 00:01:18,196 So it is the element 36 00:01:18,196 --> 00:01:19,673 wise multiplication of two 37 00:01:19,673 --> 00:01:21,500 matrices, and in general 38 00:01:21,520 --> 00:01:23,359 the P rand tends to, 39 00:01:23,380 --> 00:01:25,132 it's usually used, to denote 40 00:01:25,132 --> 00:01:27,435 element wise operations in octave. 41 00:01:27,435 --> 00:01:28,882 So, here's a matrix 42 00:01:28,882 --> 00:01:31,735 A and I'll do A dot carry 2. 43 00:01:31,735 --> 00:01:33,001 This gives me the multi, 44 00:01:33,010 --> 00:01:35,671 the element wise squaring of 45 00:01:35,690 --> 00:01:37,411 A, so 1 squared 46 00:01:37,411 --> 00:01:40,813 is 1, 2 squared is 4 and so on. 47 00:01:40,870 --> 00:01:42,215 Let's set V to a vector, 48 00:01:42,260 --> 00:01:46,085 we'll set V as 123 as a column vector. 49 00:01:46,180 --> 00:01:47,848 You can also do 1. 50 00:01:47,860 --> 00:01:49,675 over V to do 51 00:01:49,675 --> 00:01:51,533 the element wise reciprocal of 52 00:01:51,533 --> 00:01:53,176 V so this gives me 53 00:01:53,210 --> 00:01:55,600 one over one, one over two and one over three. 54 00:01:55,600 --> 00:01:56,898 This works too for matrices so 55 00:01:56,898 --> 00:01:58,436 one dot over A, gives me 56 00:01:58,470 --> 00:02:00,464 that element wise inverse of 57 00:02:00,520 --> 00:02:03,342 A. and once 58 00:02:03,342 --> 00:02:04,813 again the P radians gives use 59 00:02:04,830 --> 00:02:08,193 a clue that this is an elements wise operation. 60 00:02:08,193 --> 00:02:09,663 To also do things like log 61 00:02:09,663 --> 00:02:11,591 V This is an element wise 62 00:02:11,600 --> 00:02:14,257 logarithm of, the 63 00:02:14,257 --> 00:02:15,418 V, E to the 64 00:02:15,420 --> 00:02:17,394 V, is the base E 65 00:02:17,394 --> 00:02:20,288 exponentiation of these elements 66 00:02:20,330 --> 00:02:21,432 of this is E, this is E 67 00:02:21,432 --> 00:02:23,105 squared EQ, this is 68 00:02:23,105 --> 00:02:26,010 V. And I 69 00:02:26,120 --> 00:02:28,187 can also do apps V to 70 00:02:28,230 --> 00:02:30,172 take the element wise absolute 71 00:02:30,172 --> 00:02:32,056 value of V. So here, 72 00:02:32,056 --> 00:02:34,418 V was all positive, abs, say 73 00:02:34,430 --> 00:02:36,503 minus 1 to minus 3, 74 00:02:36,503 --> 00:02:38,543 the element wise Absolute 75 00:02:38,543 --> 00:02:40,428 value gives me back these 76 00:02:40,430 --> 00:02:43,929 non-negative values and negative 77 00:02:43,929 --> 00:02:45,465 V gives me the minus 78 00:02:45,465 --> 00:02:46,715 of V. This is the same 79 00:02:46,730 --> 00:02:49,085 as -1xV but usually 80 00:02:49,085 --> 00:02:50,653 you just write negative V and 81 00:02:50,653 --> 00:02:55,340 so that negative 1xV and what else can you do? 82 00:02:55,990 --> 00:02:57,185 Here's another neat trick. 83 00:02:57,185 --> 00:02:58,343 So Let's see. 84 00:02:58,343 --> 00:03:01,424 Let's say I want to take V and increment each of these elements by 1. 85 00:03:01,424 --> 00:03:02,520 Well, one way to do 86 00:03:02,520 --> 00:03:05,407 it is by constructing a 87 00:03:05,420 --> 00:03:09,010 3 by 1 vector 88 00:03:09,660 --> 00:03:12,666 this all ones and adding that to V. So, they do that. 89 00:03:12,666 --> 00:03:15,373 This increments V by for 123 to 234. 90 00:03:15,373 --> 00:03:16,804 The way I did 91 00:03:16,804 --> 00:03:21,439 that was length of V, is three. 92 00:03:21,890 --> 00:03:23,790 So ones, length of 93 00:03:23,790 --> 00:03:25,792 V by one, this is ones 94 00:03:25,820 --> 00:03:27,055 of three by one. 95 00:03:27,055 --> 00:03:29,525 So that's ones, three by one. 96 00:03:29,580 --> 00:03:31,150 On the right and what I 97 00:03:31,230 --> 00:03:33,198 did was B plus ones, 98 00:03:33,198 --> 00:03:35,139 V by one, which is adding 99 00:03:35,150 --> 00:03:36,605 this vector of all ones 100 00:03:36,610 --> 00:03:38,112 to B. And so this increments 101 00:03:38,112 --> 00:03:40,340 V by one. 102 00:03:40,340 --> 00:03:41,984 And you, another simpler 103 00:03:41,984 --> 00:03:44,472 way to do that is to type V+ one, right? 104 00:03:44,472 --> 00:03:45,600 So that's V and 105 00:03:45,650 --> 00:03:46,989 V+ one also means to 106 00:03:47,000 --> 00:03:49,257 add one element wise to 107 00:03:49,280 --> 00:03:52,458 each of my elements of V. 108 00:03:52,458 --> 00:03:55,422 Now, let's talk about more operations. 109 00:03:55,450 --> 00:03:58,848 So, here's my matrix A. If you want to write A transpose. 110 00:03:58,848 --> 00:04:00,841 The way to do that is to write A prime. 111 00:04:00,900 --> 00:04:02,653 That's the apostrophe symbol. 112 00:04:02,660 --> 00:04:03,770 It's the left quote. 113 00:04:03,770 --> 00:04:05,355 So, on your keyboard 114 00:04:05,355 --> 00:04:06,975 you probably have a left 115 00:04:06,975 --> 00:04:08,106 quote and a right quote. 116 00:04:08,106 --> 00:04:09,901 So this is a at the 117 00:04:09,950 --> 00:04:12,304 standard quotation mark is a, 118 00:04:12,304 --> 00:04:14,765 what to say, a transpose 119 00:04:14,765 --> 00:04:16,172 to excuse me the, you 120 00:04:16,172 --> 00:04:17,228 know, a transpose of my 121 00:04:17,228 --> 00:04:18,919 major and of course 122 00:04:18,919 --> 00:04:20,405 a transpose if I transpose 123 00:04:20,405 --> 00:04:21,650 that again then I should 124 00:04:21,650 --> 00:04:26,509 get back my matrix A. Some more useful functions. 125 00:04:26,540 --> 00:04:28,646 Let's say locate A is 126 00:04:28,646 --> 00:04:30,546 1 15 to 0.5. 127 00:04:30,546 --> 00:04:34,266 So, it's a, you know, 1 by 4 matrix. 128 00:04:34,266 --> 00:04:36,239 Let's say set val equals max 129 00:04:36,239 --> 00:04:37,833 of A. This returns the 130 00:04:37,833 --> 00:04:39,328 maximum value of A, which 131 00:04:39,328 --> 00:04:41,481 in this case is 15 and 132 00:04:41,500 --> 00:04:44,465 I can do val ind max 133 00:04:44,490 --> 00:04:47,115 A. And this returns 134 00:04:47,120 --> 00:04:49,634 val of int which are 135 00:04:49,634 --> 00:04:51,289 the maximum value of A 136 00:04:51,289 --> 00:04:52,943 which is 15 as was the index. 137 00:04:52,943 --> 00:04:56,028 So the elements number two of A that 15. 138 00:04:56,028 --> 00:04:58,766 So, in is my index into this. 139 00:04:58,766 --> 00:05:00,148 Just as a warning: if 140 00:05:00,148 --> 00:05:03,155 you do max A where A is a matrix. 141 00:05:03,180 --> 00:05:04,746 What this does is this actually 142 00:05:04,780 --> 00:05:07,848 does the column wise maximum, 143 00:05:07,860 --> 00:05:11,525 but say a little bit more about this in a second. 144 00:05:11,570 --> 00:05:13,305 So, using this example of the 145 00:05:13,305 --> 00:05:17,008 variable lowercase A. If I do A less than three. 146 00:05:17,040 --> 00:05:19,548 This does the element wise operation. 147 00:05:19,590 --> 00:05:21,063 Element wise comparison. 148 00:05:21,063 --> 00:05:22,624 So, the first element 149 00:05:22,624 --> 00:05:24,855 Of A is less than three equals to one. 150 00:05:24,855 --> 00:05:26,315 Second elements of A is 151 00:05:26,315 --> 00:05:27,435 not less than three, so 152 00:05:27,435 --> 00:05:29,948 this value is zero, because it is also. 153 00:05:29,950 --> 00:05:31,258 The third and fourth numbers of 154 00:05:31,300 --> 00:05:32,866 A are the lesson, 155 00:05:32,870 --> 00:05:35,667 I meant less than three, third and fourth elements are less than three. 156 00:05:35,667 --> 00:05:36,826 So this is one, one, so 157 00:05:36,826 --> 00:05:38,441 this is just the element wide 158 00:05:38,460 --> 00:05:40,241 comparison of all four 159 00:05:40,280 --> 00:05:42,504 element variable lower case 160 00:05:42,520 --> 00:05:44,008 three and it returns true 161 00:05:44,020 --> 00:05:47,382 or false depending on whether or not it's less than three. 162 00:05:47,400 --> 00:05:48,843 Now, if I do find 163 00:05:48,880 --> 00:05:50,708 A less than three, this would 164 00:05:50,710 --> 00:05:52,149 tell me which are the 165 00:05:52,190 --> 00:05:53,805 elements of A that the 166 00:05:53,860 --> 00:05:55,202 variable A of less than three 167 00:05:55,202 --> 00:05:56,964 and in this case the 1st, 3rd 168 00:05:56,964 --> 00:06:00,244 and 4th elements are lesson three. 169 00:06:00,244 --> 00:06:01,465 For my next example Oh, let 170 00:06:01,465 --> 00:06:03,335 me set eight be code to 171 00:06:03,340 --> 00:06:05,765 magic three. The magic 172 00:06:05,765 --> 00:06:07,409 function returns. Let's type help magic. Functions called 173 00:06:09,390 --> 00:06:12,581 The magic function returns. 174 00:06:12,581 --> 00:06:15,362 Returns this matrices called magic squares. 175 00:06:15,362 --> 00:06:17,722 They have this, you know, 176 00:06:17,740 --> 00:06:20,012 mathematical property that all 177 00:06:20,030 --> 00:06:21,590 of their rows and columns and 178 00:06:21,590 --> 00:06:23,730 diagonals sum up to the same thing. 179 00:06:23,730 --> 00:06:25,535 So, you know, it's 180 00:06:25,580 --> 00:06:27,378 not actually useful for machine 181 00:06:27,378 --> 00:06:28,385 learning as far as I 182 00:06:28,385 --> 00:06:29,688 know, but I'm just using 183 00:06:29,688 --> 00:06:31,720 this as a convenient way, 184 00:06:31,720 --> 00:06:33,058 you know, to generate a 3 185 00:06:33,058 --> 00:06:36,206 by 3 matrix and this magic square screen. 186 00:06:36,220 --> 00:06:37,228 We have the power of 3 187 00:06:37,228 --> 00:06:39,500 at each row, each column and 188 00:06:39,510 --> 00:06:41,055 the diagonals all add up 189 00:06:41,055 --> 00:06:44,487 to the same thing, so it's kind of a mathematical construct. 190 00:06:44,510 --> 00:06:45,789 I use magic, I use this 191 00:06:45,800 --> 00:06:47,110 magic function only when I'm 192 00:06:47,110 --> 00:06:48,118 doing demos, or when I'm 193 00:06:48,140 --> 00:06:49,571 teaching Octave like this and 194 00:06:49,580 --> 00:06:51,103 I don't actually use it for 195 00:06:51,103 --> 00:06:53,846 any, you know, useful machine learning application. 196 00:06:53,860 --> 00:06:59,356 But, let's see, if I type RC equals find A greater than or equals 7. 197 00:06:59,390 --> 00:07:02,657 This finds all the elements 198 00:07:02,657 --> 00:07:03,797 of a that are greater than 199 00:07:03,797 --> 00:07:05,246 and equals to 7 and 200 00:07:05,246 --> 00:07:07,044 so, RC sense a row and column. 201 00:07:07,100 --> 00:07:09,392 So, the 11 element is greater than 7. 202 00:07:09,400 --> 00:07:10,973 The three two elements is 203 00:07:10,980 --> 00:07:13,178 greater than 7 and the two 3 elements is greater than 7. 204 00:07:13,200 --> 00:07:14,788 So let's see, the two, three 205 00:07:14,800 --> 00:07:18,803 element for example, is A two, three. 206 00:07:18,850 --> 00:07:21,102 Is seven, is this element 207 00:07:21,120 --> 00:07:24,248 out here, and that is indeed greater than or equal seven. 208 00:07:24,248 --> 00:07:26,005 By the way, I actually don't even 209 00:07:26,030 --> 00:07:27,613 memorize myself what these 210 00:07:27,613 --> 00:07:28,944 find functions do in the 211 00:07:28,960 --> 00:07:30,323 all these things do myself and 212 00:07:30,323 --> 00:07:31,399 whenever I use a find 213 00:07:31,399 --> 00:07:33,042 function, sometimes I forget 214 00:07:33,070 --> 00:07:34,791 myself exactly what does, and 215 00:07:34,791 --> 00:07:37,952 you know, type help find to look up the document. 216 00:07:37,970 --> 00:07:40,042 Okay, just two more things, if it's okay, to show you. 217 00:07:40,042 --> 00:07:41,549 One is the sum function. 218 00:07:41,549 --> 00:07:43,452 So here's my A and 219 00:07:43,452 --> 00:07:44,755 I type sum A. This adds 220 00:07:44,800 --> 00:07:46,500 up all the elements of A. 221 00:07:46,510 --> 00:07:47,660 And if I want to multiply them 222 00:07:47,660 --> 00:07:49,404 together, I type prod A. 223 00:07:49,410 --> 00:07:50,795 Prod sense of product, 224 00:07:50,800 --> 00:07:53,022 and it returns the products of 225 00:07:53,022 --> 00:07:55,773 these four elements of A. 226 00:07:56,040 --> 00:07:58,215 Floor A rounds down, 227 00:07:58,215 --> 00:07:59,465 these elements of A, so zero 228 00:07:59,470 --> 00:08:01,766 O point five gets rounded down to zero. 229 00:08:01,766 --> 00:08:03,352 And ceil, or ceiling A, 230 00:08:03,380 --> 00:08:04,815 gets rounded up, so zero 231 00:08:04,815 --> 00:08:06,212 point five, rounded up to 232 00:08:06,220 --> 00:08:10,735 the nearest integer, so zero point five gets rounded up to one. 233 00:08:10,735 --> 00:08:12,143 You can also. 234 00:08:12,143 --> 00:08:13,322 Let's see. 235 00:08:13,322 --> 00:08:14,418 Let me type rand 3. 236 00:08:14,418 --> 00:08:16,643 This generally sets a 3 by 3 matrix. 237 00:08:16,680 --> 00:08:20,444 If I type max randd 3, rand 3. 238 00:08:20,460 --> 00:08:21,848 What this does is it takes 239 00:08:21,848 --> 00:08:24,963 the element wise maximum of 240 00:08:24,963 --> 00:08:26,897 2 random 3 by 3 matrices. 241 00:08:26,900 --> 00:08:28,017 So, you'll notice all these 242 00:08:28,017 --> 00:08:29,063 numbers tend to be a bit on the 243 00:08:29,063 --> 00:08:30,948 large side because each of 244 00:08:30,948 --> 00:08:32,581 these is actually the max of 245 00:08:32,581 --> 00:08:35,093 a randomly, of element Y's 246 00:08:35,110 --> 00:08:38,269 max of two randomly generated matrices. 247 00:08:38,269 --> 00:08:40,316 This is my magic number. 248 00:08:40,316 --> 00:08:43,258 This was my magic square 3x3a. 249 00:08:43,258 --> 00:08:47,704 Let's say I type max A and then this will be it. 250 00:08:47,730 --> 00:08:49,955 Open, close, square brackets comma 1. 251 00:08:49,955 --> 00:08:51,344 What this does is 252 00:08:51,360 --> 00:08:53,584 this takes the column wise maximum. 253 00:08:53,600 --> 00:08:54,892 So, the maximum of the 254 00:08:54,910 --> 00:08:56,517 first column is eight, max 255 00:08:56,517 --> 00:08:58,335 of the second column is nine, 256 00:08:58,335 --> 00:09:00,695 the max of the third column is seven. 257 00:09:00,695 --> 00:09:02,064 This 1 means to take the 258 00:09:02,100 --> 00:09:03,665 max along the first dimension of 259 00:09:03,700 --> 00:09:05,860 A. In contrast, if 260 00:09:05,940 --> 00:09:07,874 I were to type max a, this 261 00:09:07,910 --> 00:09:10,033 funny notation 2 then this 262 00:09:10,033 --> 00:09:12,433 takes the per row maximum. 263 00:09:12,460 --> 00:09:13,449 So, the maximum for the first 264 00:09:13,449 --> 00:09:14,525 row is 8, max of 265 00:09:14,560 --> 00:09:16,561 second row is 7, max 266 00:09:16,580 --> 00:09:18,105 of the third row is 9 267 00:09:18,105 --> 00:09:21,605 and so this allows you to take maxes. 268 00:09:21,605 --> 00:09:24,771 You know, per row or per column. 269 00:09:24,780 --> 00:09:26,988 And if you want to, and 270 00:09:26,988 --> 00:09:29,019 remember it defaults to column 271 00:09:29,020 --> 00:09:30,091 mark wise elements on this, 272 00:09:30,091 --> 00:09:31,628 so if you want to find 273 00:09:31,630 --> 00:09:33,395 the maximum element in 274 00:09:33,395 --> 00:09:35,040 the entire matrix A, you 275 00:09:35,040 --> 00:09:36,985 can type max of max 276 00:09:36,985 --> 00:09:39,558 of A, like so, which is nine. 277 00:09:39,558 --> 00:09:40,640 Or you can turn A into 278 00:09:40,670 --> 00:09:42,507 a vector and type max 279 00:09:42,507 --> 00:09:44,739 of A colon, like 280 00:09:44,750 --> 00:09:46,912 so, this treats this as a vector 281 00:09:46,912 --> 00:09:51,539 and takes the max element of vector. 282 00:09:51,572 --> 00:09:54,288 Finally, let's set A 283 00:09:54,288 --> 00:09:56,234 to be a nine by nine magic square. 284 00:09:56,234 --> 00:09:57,853 So remember, the magic square 285 00:09:57,853 --> 00:09:59,969 has this property that every 286 00:09:59,969 --> 00:10:03,535 column in every row sums the same thing and also the diagonals. 287 00:10:03,535 --> 00:10:06,209 So here is 9X9 magic square. 288 00:10:06,240 --> 00:10:07,715 So let me just sum A one 289 00:10:07,715 --> 00:10:10,169 so this does a per column sum. 290 00:10:10,190 --> 00:10:11,104 And so I'm going to take each 291 00:10:11,104 --> 00:10:12,194 column of A and add 292 00:10:12,194 --> 00:10:13,698 them up and this, you 293 00:10:13,700 --> 00:10:15,365 know, lets us verify that indeed 294 00:10:15,365 --> 00:10:16,935 for 9 by 9 magic square. 295 00:10:16,935 --> 00:10:20,124 Every column adds up to 369 as of the same thing. 296 00:10:20,124 --> 00:10:22,020 Now, let's do the row wise sum. 297 00:10:22,020 --> 00:10:24,643 So, the sum A comma 2 298 00:10:24,643 --> 00:10:27,967 and this sums 299 00:10:28,030 --> 00:10:29,269 up each row of A 300 00:10:29,269 --> 00:10:30,522 and each row of A 301 00:10:30,522 --> 00:10:32,113 also sums up to 369. 302 00:10:32,113 --> 00:10:34,485 Now let's sum the 303 00:10:34,500 --> 00:10:35,934 diagonal elements of A 304 00:10:35,990 --> 00:10:37,362 and make sure that they, that 305 00:10:37,370 --> 00:10:39,696 that also sums up to the same thing. 306 00:10:39,730 --> 00:10:40,924 So what I'm going to 307 00:10:40,924 --> 00:10:42,613 do is, construct a nine 308 00:10:42,613 --> 00:10:44,325 by nine identity matrix, that's 309 00:10:44,360 --> 00:10:46,018 I9, and let me 310 00:10:46,018 --> 00:10:49,326 take A and construct, multiply 311 00:10:49,326 --> 00:10:51,272 A elements wise. 312 00:10:51,300 --> 00:10:52,812 So here's my matrix of A. 313 00:10:52,812 --> 00:10:56,350 I'm gonna do A.xI9 and what 314 00:10:56,490 --> 00:10:58,018 this will do is take the 315 00:10:58,020 --> 00:11:00,035 element wise product of these 316 00:11:00,035 --> 00:11:01,150 2 matrices, and so this 317 00:11:01,150 --> 00:11:03,605 should wipe out everything except 318 00:11:03,680 --> 00:11:06,421 for the diagonal entries and now 319 00:11:06,421 --> 00:11:08,761 I'm going to sum, sum of 320 00:11:08,780 --> 00:11:11,179 A of that and this 321 00:11:11,180 --> 00:11:14,512 gives me the sum of 322 00:11:14,512 --> 00:11:16,684 these diagonal elements, and indeed it is 369. 323 00:11:16,684 --> 00:11:20,218 You can sum up the other diagonal as well. 324 00:11:20,240 --> 00:11:22,385 So this top left to bottom right. 325 00:11:22,400 --> 00:11:24,158 You can sum up the opposite diagonal 326 00:11:24,180 --> 00:11:26,832 from bottom left to top right. 327 00:11:26,832 --> 00:11:30,199 The sum, the commands for this is somewhat more cryptic. 328 00:11:30,200 --> 00:11:31,535 You don't really need to know this. 329 00:11:31,540 --> 00:11:33,122 I'm just showing you just in 330 00:11:33,122 --> 00:11:34,779 case any of you are curious, 331 00:11:34,779 --> 00:11:37,543 but let's see. 332 00:11:37,600 --> 00:11:41,235 Flip UD stands for flip up/down. 333 00:11:41,235 --> 00:11:42,622 If you do that, that turns out 334 00:11:42,622 --> 00:11:44,376 to sum up the 335 00:11:44,376 --> 00:11:46,055 elements in the opposites of, 336 00:11:46,055 --> 00:11:49,387 the other diagonal that also sums up to 369. 337 00:11:49,390 --> 00:11:51,116 Here, let me show you, 338 00:11:51,120 --> 00:11:53,055 whereas i9 is this 339 00:11:53,070 --> 00:11:57,300 matrix, flip up/down of 340 00:11:57,370 --> 00:11:58,986 i9, you know, takes the identity 341 00:11:58,986 --> 00:12:00,832 matrix and flips it vertically 342 00:12:00,832 --> 00:12:01,822 so you end up with, excuse me, 343 00:12:01,822 --> 00:12:04,394 flip UD, end up 344 00:12:04,400 --> 00:12:08,742 with ones on this opposite diagonal as well. 345 00:12:08,770 --> 00:12:10,430 Just one last command and then 346 00:12:10,490 --> 00:12:12,706 that's it, and then that will be it for this video. 347 00:12:12,760 --> 00:12:13,730 Let's say A to be the 348 00:12:13,730 --> 00:12:16,112 3x3 magic square 349 00:12:16,112 --> 00:12:17,221 again. If you want 350 00:12:17,221 --> 00:12:18,493 to invert the matrix, you 351 00:12:18,493 --> 00:12:20,668 type P inv A, this 352 00:12:20,668 --> 00:12:23,612 is typically called a pseudo inference, but it doesn't matter. 353 00:12:23,612 --> 00:12:24,991 Think of it as basically the inverse 354 00:12:24,991 --> 00:12:26,927 of A and that's the 355 00:12:26,960 --> 00:12:28,313 inverse of A and second 356 00:12:28,313 --> 00:12:31,721 set, you know, 10 equals p 357 00:12:31,740 --> 00:12:33,596 of A and of temp times 358 00:12:33,596 --> 00:12:35,362 A. This is indeed the 359 00:12:35,362 --> 00:12:37,252 identity matrix with essentially ones 360 00:12:37,260 --> 00:12:38,753 on the diagonals and zeros on 361 00:12:38,753 --> 00:12:43,322 the off-diagonals, up to a numerical round-off. 362 00:12:44,120 --> 00:12:45,746 So, that's it for how 363 00:12:45,750 --> 00:12:48,430 to do different computational operations 364 00:12:48,430 --> 00:12:50,865 on the data in matrices. 365 00:12:50,890 --> 00:12:53,055 And after running a 366 00:12:53,055 --> 00:12:54,350 learning algorithm, often one of 367 00:12:54,380 --> 00:12:55,876 the most useful things is to 368 00:12:55,900 --> 00:12:57,223 be able to look at your 369 00:12:57,230 --> 00:13:00,013 results, or to plot, or visualize your result. 370 00:13:00,020 --> 00:13:01,675 And in the next video I'm 371 00:13:01,675 --> 00:13:03,233 going to very quickly show you 372 00:13:03,233 --> 00:13:04,230 how, again, with one or 373 00:13:04,300 --> 00:13:06,261 two lines of code using Octave 374 00:13:06,270 --> 00:13:07,814 you can quickly visualize your 375 00:13:07,850 --> 00:13:09,901 data, or plot your data 376 00:13:09,901 --> 00:13:11,101 and use that to better 377 00:13:11,101 --> 00:13:14,880 understand, you know, what your learning algorithms are doing.