Let's get started with our linear algebra review.
In this video I want to
tell you what are matrices and what are vectors.
A matrix is a
rectangular array of numbers
written between square brackets.
So, for example, here is a
matrix on the right, a left square bracket.
And then, write in a bunch of numbers.
These could be features from
a learning problem or it could
be data from somewhere else, but
the specific values don't matter,
and then I'm going to close it with another right bracket on the right.
And so that's one matrix.
And, here's another example of
the matrix, let's write 3, 4, 5,6.
So matrix is just another
way for saying, is a
2D or a two dimensional array.
And the other piece
of knowledge that we need is
that the dimension of the
matrix is going to
be written as the
number of row times the number of columns in the matrix.
So, concretely, this example
on the left, this
has 1, 2, 3, 4
rows and has 2 columns,
and so this example on the
left is a 4 by
2 matrix - number of rows by number of columns.
So, four rows, two columns.
This one on the right, this matrix has two rows.
That's the first row, that's
the second row, and it has three columns.
That's the first column, that's the
second column, that's the third
column So, this second
matrix we say it is
a 2 by 3 matrix.
So we say that the dimension of this matrix is 2 by 3.
Sometimes you also see this
written out, in the case
of left, you will see this
written out as R4 by 2
or concretely what people
will sometimes say this matrix
is an element of the set R 4 by 2.
So, this thing here, this
just means the set of all
matrices that of dimension
4 by 2 and this thing
on the right, sometimes this is
written out as a matrix that is an R 2 by 3.
So if you ever see, 2 by 3.
So if you ever see
something like this are 4 by
2 or are 2 by 3,
people are just referring to
matrices of a specific dimension.
Next, let's talk about how
to refer to specific elements of the matrix.
And by matrix elements, other than
the matrix I just mean
the entries, so the numbers inside the matrix.
So, in the standard notation,
if A is this
matrix here, then A sub-strip
IJ is going to refer
to the i, j entry,
meaning the entry in
the matrix in the ith row and jth column.
So for example a1-1 is
going to refer to the entry
in the 1st row and
the 1st column, so that's the
first row and the first
column and so a1-1
is going to be equal to
1, 4, 0, 2.
Another example, 8 1
2 is going to refer to
the entry in the first
row and the second
column and so A
1 2 is going to be equal to one nine one.
This come from a quick examples.
Let's see, A, oh let's
say A 3 2, is going to refer
to the entry in the 3rd
row, and second column,
right, because that's 3 2
so that's equal to 1 4 3 7.
And finally, 8 4 1
is going to refer to
this one right, fourth row,
first column is equal to
1 4 7 and if,
hopefully you won't, but if
you were to write and say
well this A 4
3, well, that refers to
the fourth row, and the
third column that, you know,
this matrix has no third
column so this is undefined,
you know, or you can think of this as an error.
There's no such element as
8 4 3, so, you know, you
shouldn't be referring to 8 4 3.
So, the matrix
gets you a way of letting
you quickly organize, index and access lots of data.
In case I seem to be
tossing up a lot of
concepts, a lot of new notations
very rapidly, you don't need
to memorize all of this, but
on the course website where we
have posted the lecture notes,
we also have all of these definitions written down.
So you can always refer back,
you know, either to these slides,
possible coursework, so audible lecture
notes if you forget well, A41 was that?
Which row, which column was that?
Don't worry about memorizing everything now.
You can always refer back to
the written materials on the course website, and use that as a reference.
So that's what a matrix is.
Next, let's talk about what is a vector.
A vector turns out to be a special case of a matrix.
A vector is a matrix
that has only 1 column so
you have an N x 1
matrix, then that's a remember, right?
N is the number of
rows, and 1 here
is the number of columns, so, so
matrix with just one column
is what we call a vector.
So here's an example
of a vector, with I
guess I have N equals four elements here.
so we also call this
thing, another term for
this is a four dmensional
vector, just means that
this is a vector with four
elements, with four numbers in it.
And, just as earlier
for matrices you saw this
notation R3 by 2
to refer to 2 by
3 matrices, for this vector
we are going to refer to this
as a vector in the set R4.
So this R4 means a
set of four-dimensional vectors.
Next let's talk about how to refer to the elements of the vector.
We are going to use the notation
yi to refer to
the ith element of the
vector y. So if y
is this vector, y subscript i is the ith element.
So y1 is the
first element,four sixty, y2
is equal to the second element,
two thirty two -there's the first.
There's the second.
Y3 is equal to
315 and so on, and
only y1 through y4 are
defined consistency 4-dimensional vector.
Also it turns out that
there are actually 2 conventions
for how to index into a
vector and here they are.
Sometimes, people will use
one index and sometimes zero index factors.
So this example on the left
is a one in that
specter where the element
we write is y1, y2, y3, y4.
And this example in the right
is an example of a zero index
factor where we start
the indexing of the elements from zero.
So the elements go from a zero up to y three.
And this is a bit like the
arrays of some primary languages
where the arrays can either
be indexed starting from one.
The first element of an
array is sometimes a Y1,
this is sequence notation I guess,
and sometimes it's zero index
depending on what programming language you use.
So it turns out that in
most of math, the one
index version is more
common For a lot
of machine learning applications, zero index
vectors gives us a more convenient notation.
So what you should usually
do is, unless otherwised specified,
you should assume we are using one index vectors.
In fact, throughout the rest
of these videos on linear algebra
review, I will be using one index vectors.
But just be aware that
when we are talking about machine learning
applications, sometimes I will
explicitly say when we
need to switch to, when we
need to use the zero index
vectors as well.
Finally, by convention, usually
when writing matrices and vectors,
most people will use upper
case to refer to matrices.
So we're going to use
capital letters like
A, B, C, you know,
X, to refer to matrices,
and usually we'll use lowercase,
like a, b, x, y,
to refer to either numbers,
or just raw numbers or scalars or to vectors.
This isn't always true but
this is the more common
notation where we use
lower case "Y" for referring
to vector and we usually
use upper case to refer to a matrix.
So, you now know what are matrices and vectors.
Next, we'll talk about some
of the things you can do with them