And so that's another interesting little shortcut or it just, I would say,

interesting little fact about creating variances.

Is that all we need to do is sort of sandwich in between the two vectors,

this matrix, to create the collection of squared deviations.

So let me give you another example that is quite useful.

Let's suppose you have a matrix x, which is n by p, okay?

And you took x transpose times I minus jn,

jn transpose, jn inverse,

jn transpose, times x.

Well again, remember, if we pre-multiply x,

if we pre-multiply x by that matrix, it's going to center all the columns.

So, and if we then pre-multiply,

post-multiply by it, multiply on the right by it.

This is gonna center all the rows of x transpose,

which is centering all the columns of x.

Again, so this is say, x tilde transpose times x tilde.

And again, because it's idempotent,

it's having one in the middle there, it's just like having two.

So because of that, this equation right here

is exactly x tilde transpose times x tilde.

And if you look at that, if you look at this matrix, okay?

The result is nothing other than a matrix where every diagonal element.

Is the squared deviations around that particular column of x.

And every off diagonal element is the cross deviations of that

particular column minus its mean, times another particular column minus its mean.

And so this matrix, if we then multiply it times 1 over n minus 1,

is the so called variance-covariance matrix.

Down the diagonal are the variances of the columns,

while the off-diagonals are the covariances.

Between the ith and jth column in the ij of diagonl entry.

So you can see that with this matrix manipulation,

it's actually quite easy to arithmetically arrive at a covariance matrix.

Without actually having to write any loops if you have matrix arithmetic defined.

So why don't we go through a coding example just to show this.

And then we'll be done with some of our basic matrix algebra prerequisites.

Hopefully this will have gotten us into the mode and the mindset for

using matrices and block partition manipulations of matrices.

That we're gonna need a lot throughout the class.

And if you're getting a little bit lost now,

we're gonna keep going over these concepts over and over and over again.

So you'll get very, very much so familiar with them later on in the class.