All language subtitles for 8. Matrix Training Exercises - Solutions Walkthrough

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian Download
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

1

Hello everyone and welcome to the lecture on our matrix exercise solutions.

2

Walk through in this lecture video.

3

I'm going to be going over the solutions for the Art Matrix exercises and explaining as we go along

4

.

5

Let's jump to our studio and get started.

6

OK.

7

So here we are our studio.

8

I want to hit him just showing the scripting and the cons. windows.

9

The first question or exercise we had to perform was to create two vectors and B were A's 1 2 3 and

10

B is 4 5 6.

11

Those vectors we had to use the C binder are Byne functions create a two by three Matrix from the vectors

12

and we'll need to figure out which of these binding functions is the correct choice.

13

Let's go ahead and get started.

14

Well go ahead and assign a and we use the combined function that's the lowercase c and we'll do a similar

15

process for creating B 4 5 6.

16

And then what we had to do is figure out whether to use C bind or bind.

17

So what's the actual difference here number that see Byne will bind columns together.

18

So if we did see binds we would have a result that is a three by two Matrix and the instructions asked

19

for a two by three.

20

I mean the correct answer was to use our bind AB.

21

And here we have our matrix.

22

Let's go ahead and move on to exercise.

23

Question number two.

24

Exercise 2 was to create a three by three matrix consisting of the numbers 1 through 9.

25

We had to create this met matrix using the shortcut.

26

One call and nine is by specifying the n row argument in the matrix function call.

27

Let's assign this matrix the variable M-80.

28

Matt when you go ahead and clear the con..

29

So just a quick reminder of what the actual shortcut looks like.

30

This one Colan nine that creates a sequence of integers.

31

So for example instead of having to write the combined function one two three for a continuous sequence

32

of integers I can just say one colon three.

33

And the syntax is your starting integer colon to your ending last in the integer.

34

So how do we actually use this with the Matrix call or we're going to say matrix function will pass

35

in one call in nine and then we're going to say by RHO equals true and we'll say number of rows is equal

36

to 3.

37

In order to have it be a three by three it's go to check to make sure that looks correct.

38

One two three four five six seven eight nine.

39

Everything's looking good.

40

Let's go in and save that to the variable M-80.

41

So I'll take that same command and I will sign it to the variable Max.

42

And that's how we answer that question.

43

A quick note.

44

If you didn't specify by rote the equal true that's OK as well.

45

So if he did something like this and ran that that would give you filled out by the columns which is

46

also an acceptable answer doesn't really matter.

47

You don't do by RHO true since it wasn't specified for this particular question.

48

Let's go ahead and move on to the next question.

49

All right.

50

Question number three was to confirm that M-80 variable is a matrix.

51

Using is dot matrix.

52

Let me go and explain how that is that Matrix actually works.

53

I'm going to say is dots.

54

And you'll notice our studio will actually have a huge drop down menu of all the things we can check

55

.

56

So the is the methods are really useful if you're trying to check what data type data structure you're

57

working with.

58

Then in this case we're going to go ahead and check if something is a matrix.

59

So you end up doing is say is that matrix and you pass in the variable you want to check and it'll return

60

true because the M-80 variable is a matrix and you can actually use the same sort of operation for any

61

data type.

62

So if I go in and clear the console and say Is dots we can check if something is an array.

63

So we can go ahead and pass in MIT and we get true in this case because Matrix's do count as a form

64

of an array.

65

Notice an array is not the same as a vector.

66

You can think of a matrix as just a two dimensional array.

67

But if we do something like check is dot for instance data frame which will learn about in more detail

68

later we pass and met we get false because a matrix and a data frame aren't the same thing.

69

Let's go ahead and move on to the next question.

70

Number four exercise for was to create a five by five matrix consisting of the numbers 1 through 25

71

and assign it to the variable M-80 2 and the top row should be the numbers 1 through 5.

72

So we're going to do this really Similarly it's how we just did the last Matrix.

73

I'm going to go ahead and say Matt 2 for my variable name and then I will pass in the matrix function

74

.

75

I'll use that shortcut to quickly create a vector one through 325.

76

Notice it said the top row should be the numbers 1 through 5 meaning I want to fill this out by rows

77

not by columns.

78

So since my columns is the default meaning by rows is false.

79

And I go ahead and say by row capital-T for true.

80

And then finally I want this to be a five by five matrix.

81

So I want the number of rows to be five.

82

Let's go ahead and check that too.

83

It looks like everything worked well.

84

We have a five by five Matrix and we have one two three four five.

85

OK moving on to the next question using indexing notation.

86

Grab a subsection of Matt 2 from the previous exercise that looks like this 7 comma 8 12 comma 13.

87

All right let's go ahead and do that.

88

So let's go in and locate where 7 8 12 13 would be in or M8 to are meant to object.

89

Looks like it's 78 right here in columns 2 and 3 wrote 2.

90

And then we also have in the same columns 2 and 3 but row 3 total 13.

91

So essentially want to grab this square chunk out of our matrix.

92

Let's go ahead and do that well you use bracket notation.

93

Or the indexing notation that we learned earlier.

94

First thing I want to do is pass in the rows that I want in this case I want rows two through three

95

.

96

So one way I can do that is just by using that colon rotation rows two three three and actually want

97

this exact same columns.

98

So say comma exactly mutation and if I run that we get that result 7 8 12 13 to enter two times it goes

99

up a bit.

100

But here it is.

101

So this is the correct way that index for that.

102

Let's move on to the next exercise which is also an index notation exercise and for this exercise we

103

want it to again grab a subsection that now looks like this 19 20 and 24 25.

104

Looking again at our math to object we have 19 20 and 24 25 looks like that's a two by two subsection

105

in rows and columns 4 5 and 4 5.

106

So how do we do this.

107

Well again it's going to be really similar.

108

Hopefully if he did the last one you'll be able to answer this one as well.

109

We're going in clear the councils we have in a Froom.

110

I'll say I'm at 2 again so you can see it.

111

I want 19 20 and 24 25.

112

So again pass met to a pass in the rows that I want which is rows 4 through 5.

113

And then I pass the columns I want which again is Aurthur 5.

114

And there we have that subsection in the matrix.

115

As mentioned during the matrix lectures it's really useful if you're struggling with this concept of

116

rows common columns to just in your mind grab subsections of the matrix and then try to index them.

117

So do a quick example of this.

118

In case you're struggling this concept let's say I wanted to grab seven eight nine ten and then 12 13

119

14 15.

120

So a rectangular Matrix.

121

Well I just identify the rows that I want so two three and it passes into Colon three and then identify

122

the columns I want which is two three four five.

123

So let's to call in five and I get this answer as a result.

124

Again that's not an actual exercise question in this case.

125

Just an example of how you can break this problem down.

126

So if you're struggling with this make sure you practice it a lot just by choosing subsections and trying

127

to get them out.

128

Let's go to move on to the next exercise which was exercise 7.

129

The question was What is the sum of all the elements in Mat 2.

130

How do we actually do that.

131

Well you can clear the console and we just use the sum function so we can say some math too.

132

So hopefully to discover that if you just say some math to it will sum all the elements.

133

Quick side note if you're looking to some just the columns or just the rows you can add additional arguments

134

like call some's or sum up the column so we can go in and say I met two and then row sums.

135

Works for the rows.

136

All right.

137

So those are just quick side notes.

138

But in this case if you want to do all the elements shust normal some moving on we have one more exercise

139

.

140

And it was this.

141

Find out how to use run I if this function to create a four by five matrix consisting of 20 random numbers

142

four times five is equal to 20.

143

All right let's go ahead and see how he would do this.

144

First thing I'm going to assume that you've never actually seen this function before run.

145

So I want to find out how to use it.

146

Meaning I want to help on this.

147

I'll say help.

148

And pasan.

149

Ron I-F and then boom we have a nice help tab here and we see what the arguments look like and what

150

we should actually do.

151

So what actually is run I.

152

Well it's a uniform distribution.

153

And what that means is these functions essentially provide information with the uniform distribution

154

from the interval from min to Max.

155

So how do we actually do this.

156

We look here and notice we have a few uniform distribution functions.

157

But the last one here is run.

158

The one we referred to is a little small so hopefully you can call as far as font size.

159

You can call help here and that spoiler's yourself.

160

But if I just go in and copy this so we can see what it's actually saying in the documentation it says

161

run a f n comma min equals zero Max equals 1.

162

So those are the parameters or arguments we have to pass into this function and if we check out the

163

documentation for what it is it says and is a number of observations.

164

All right so we know we want 20 random numbers.

165

So that means I want to draw 20.

166

If I go yes go ahead and say run I if I pass in 20 and looks like it returns a vector of 20 random numbers

167

.

168

Perfect.

169

Now I can also specify min and max value.

170

So for instance right now I'm just doing random numbers.

171

Frean the defaults and the defaults were 0 and 1.

172

But if I go ahead and say run I if it's a random uniform distribution pass in 20 values I can also specify

173

what I want the min value to be and the Max might be.

174

So if I wanted to pick numbers tween 0 and 100 I could say many equals zero.

175

And I could change my max to be 100.

176

And now I get 25 or 20 random numbers between 0 and 100 in the solutions notebook I show putting in

177

the men and the max.

178

You don't actually have to do that.

179

You could have just run run f 20.

180

Let's go ahead and go with min and max settings.

181

So how do we actually perform this.

182

As far as creating this matrix of a four by five consisting of these when he ran the numbers will you

183

just say matrix and then we pass in run I f 20

184

and we wants four rows who want a four by five matrix and there is our matrix.

185

And notice here even though it's printing out like this is a four by five.

186

I'm going to go ahead and do is expand the window a bit.

187

You can always check by what the index locations are the dimensions of your matrix.

188

But if I run this again then we can see for sure that it's a four by five matrix.

189

All right mixture of the notebook in case you're confused on anything but remember the main point of

190

this last question was to get you used to reading help on functions that you don't know about and learning

191

how to use them.

192

All right.

193

Hopefully that wasn't too bad.

194

Make sure review the matrix lectures in case you're unsure of anything we just covered.

195

Thanks and I'll see you at the next lecture

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.