2:15

And so from the perspective of our new coordinate frame

Â v will be a different vector.

Â How can we find the representation of v in our new coordinate frame?

Â Well this is not too complicated.

Â What we want to do is find out how much v goes over in the x1 direction and

Â how much v goes over in the x2 direction and how can we do that?

Â What we're going to do is we're going to project v onto a unit vector x1,

Â hat, x1 new hat for the new unit vector in the direction of x1.

Â And the projection of v onto x1 new hat,

Â the unit vector pointing in the direction x1 new,

Â will give us the amount that v lines up with the x1 new direction.

Â And in the same way the projection of v on to x2 new hat,

Â the unit vector pointing in the x2 new direction

Â will give us the amount that v points in the x2 new direction, so v2 new.

Â So, how do we actually write out the math?

Â So, if we were to write, v1 new, what does that equal?

Â That just equals, the projection of v

Â onto the unit vector, pointing in our x1 new direction.

Â And as we learned in earlier weeks, that's just the dot product between v and

Â x1 new hat.

Â It's important that x1 new hat is a unit vector so

Â that v1 new isn't scaled by an unnecessary amount.

Â And likewise,

Â v2 new = v x2 new.

Â And so how can we write out this equation as a matrix?

Â Well, dot products are very easy things to stick into matrix equations.

Â So we can write v1 new,

Â the vector v1 new is equal to some matrix times

Â our v old, sorry that should be v new not v1 new.

Â And this matrix is our change of basis matrix.

Â And in each row of our change of basis matrix we have

Â a row vector corresponding to one of the new basis vectors.

Â So the top row of our change of basis matrix

Â is the row vector for x1 new hat and

Â the bottom row is the row vector for x2 new hat.

Â We write the little t to indicate the transpose,

Â meaning that weâ€™re taking a column vector to a row vector.

Â So in this case x is a 2 x 2 matrix.

Â So let's go through an example,

Â we'll draw out our original x1 old as one axis.

Â And x2 old as the other and

Â let's draw the vector so

Â v old will be, how about 1, 4.

Â So it goes over 1 and that's one that's 4,

Â not perfectly proportioned but that's okay.

Â How would we represent this vector in a coordinate frame

Â that has been rotated 45 degrees?

Â Well, the first thing we need is to make our change of basis matrix.

Â So, we need to find the unit vectors x1 hat new and

Â x2 hat new that point in the directions of our new axes.

Â Well, this is just a trigonometry problem, so we can right the x1 hat

Â new is equal to 1 over the square root of 2,

Â 1 over the square root of 2.

Â Because if it's at 45 degrees,

Â it has to go up as much as it goes over and the square root of 2 term

Â comes in because the magnitude of this vector has to be equal to 1.

Â Similarly, x2 hat new is equal to,

Â while we go over minus 1 over square root of 2 and up 1 over square root of 2.

Â This allows us to write our change of basis matrix x.

Â So how did we do that?

Â What we did was we brought x1 hat new to the top row.

Â So we have 1 over square root of 2, 1 over square root of 2 and

Â we have x hat 2 new in the bottom row.

Â So that's minus 1 over square root of 2, 1 over square root of 2.

Â So then how do we write V new?

Â Well from our equation,

Â that was equal to x times v old.

Â And remember when you multiply a matrix by a column vector, what you're doing is

Â taking the dot product of each row of the matrix with the column vector.

Â So this equals 1 over root 2,

Â 1 over root 2 minus 1 over root 2,

Â 1 over root 2 times 1, 4.

Â So now doing this matrix multiplication, gives us 1 over square root of 2,

Â plus four4 over square root of 2, in the top.

Â So that's 5 over square root of 2 and minus 1 over square root of 2 + 4

Â over square root of 2 in the bottom so that's 3 over square root of 2.

Â And that equals about 3.5 and 2.1.

Â So in our new coordinate frame we go over 3.5 and

Â up 2.1 and that's all she wrote.

Â All right, so here's some intuition.

Â If you have a vector v, it's really the same vector in kind of a deeper way,

Â regardless of what basis you represent it in.

Â I could represent v in the old basis, or the new basis,

Â or maybe even a newer basis, newer x2, newer.

Â But regardless of what basis I represent v itself doesn't actually change.

Â The only thing that changes is the numbers we use to describe v.

Â And so the change in basis formula tells you how to find the numbers

Â that describe v in one basis, given the numbers that describe v in another basis.

Â As well as your change of basis matrix,

Â which relates the old basis and the new basis.

Â But v as kind of an abstract entity is still basically the same thing,

Â regardless of your representation.

Â In kind of the same way that a certain object is the same object

Â regardless of what angle you see it from.

Â So hopefully the idea of representing a vector in

Â a different basis doesn't theme all that crazy.

Â However, what does it mean to represent a matrix in a new basis?

Â So let's we had A matrix A old =

Â ( a11 old a12 old a21 old

Â a22 old) What does it mean to

Â change the basis of the matrix?

Â Well, unfortunately it's not quite as simply

Â representing each of the columns of A in the new basis.

Â But even if that would be more simple it wouldn't be very useful.

Â So what is a matrix?

Â Or what does it do?

Â What a matrix does, is to take one vector, so a matrix takes the vector v,

Â v old, and it maps it to a new vector.

Â So this new vector is A old times v old and that's all it does.

Â A matrix takes one vector and spits out a new vector.

Â And if it's a square matrix then it'll spit out the new vector in the same

Â vector space as the old vector.

Â So that's kind of nice.

Â And very often in neuroscience,

Â we will be working with square matrices, so that makes life easy.

Â Okay, so, what would it mean to write A new,

Â what would it mean to represent A in a new basis?

Â Well, we saw that v was kind of this abstract entity

Â that stayed the same in a lot of ways, regardless of which basis you were in.

Â So, if we change our representation of v old to v new,

Â so we do our change of bases formula and get the old represented in a new bases.

Â We want A new to have the same action on v

Â new as A old had on v old.

Â So we want to choose A new such that it does the same thing

Â to v new as A old did to v old.

Â We should find the representation of the matrix that preserves its action.

Â So A old, v old, that's just a vector, right?

Â So we can represent it

Â in our new representation by multiplying it by x, right?

Â So this is the new representation of A old v old.

Â So what do we want that to be equal to?

Â Well, we want the representation of A old, v old in the new basis

Â to be equal to A in the new basis multiplied by v in the new basis.

Â So all this says is that A new times v new is A old times v old but

Â represented in the new basis.

Â But what equation do we have for v new?

Â Well we know that v new is equal to x times v old.

Â So we can write A new times x

Â v old is equal to x times A old,

Â v old and then if we multiplied both

Â sides of this equation by x inverse,

Â we get x inverse times

Â A new times x times v old is

Â equal to A old times v old.

Â 16:25

you multiply that vector by your change of basis matrix.

Â And to represent a matrix in the new basis,

Â you multiply the matrix on the left by your change of basis matrix.

Â And on the right by the inverse of your change of basis matrix.

Â And just to recall, x was composed such that each

Â row was a unit vector.

Â So, vector with length one pointing the direction of

Â an axis in the new basis.

Â And so we did all of this in two dimensions.

Â But these equations hold no matter if you have three dimensions, four dimensions, or

Â even an infinite number of dimensions.

Â So that is how you change basis.

Â So just one example of when changing basis might be useful and

Â we actually talked about this earlier on in the course

Â when we mentioned principal components analysis.

Â And in principal components analysis, the basic idea is that

Â you have a bunch of vectors that have been drawn from some random distribution.

Â And depending on the distribution they're drawn from, they might be aligned along

Â some other axes that has rotated compared to the coordinate frame you started with.

Â So in PCA, what we do is we change the basis of all

Â of the vectors from our random distributions,

Â such that they line up mostly along one or two or

Â a small number of those axes.

Â And what this does is to help decorrelate the components of the vector.

Â So in our old basis x1 and x2 were very correlated.

Â When x1 went up, x2 went up and when x2 went down, x1 went down.

Â But in our new basis x1 new and x2 new,

Â the components of the vectors are uncorrelated, so

Â that makes things a lot easier when you're working with probability distributions.

Â