Derivative of a Matrix : Data Science Basics
Вставка
- Опубліковано 27 вер 2024
- What does it mean to take the derviative of a matrix?
---
Like, Subscribe, and Hit that Bell to get all the latest videos from ritvikmath ~
---
Check out my Medium:
/ ritvikmathematics
My Patreon:
www.patreon.co...
"Please, take a minute to pause and convince yourself that everything on this board is accurate." So difficult to do when I was in school ("several" moon ago) madly scribbling down everything before it got wiped off the board, but now with the internet, with videos, and most importantly with a person who wants you to learn, this is so much easier to absorb. I'm looking forward to teaching my children and using your wise words. Thank you!
Don't homeschool your kids! you'll screw them up for life!
@@REALdavidmiscarriage And your evidence for this is..? Homeschool has issues, but so does regular schooling.
@@berylliosis5250 dude in my line of work I got to know a lot of people who have been homeschooled and they all show anti social tendencies and varying degrees of depression, but most of all they all hate their parents for forcing them into being homeschooled. most of them have an extremely hard time making friends or socialising with others. how are you supposed to learn to work in a group with kids in your age, if you don't have the social construct of a school. Also why not trust people who have studied a subject for years to teach your kids, over your own superficial knowledge of science and literatur. Also it's almost always the parents who want this whole homeschooling thing never the children. Cause they have serious attachment problems with their kids and can't let go of them because they are so obsessive. please get over yourselves hoomschooling parents!
@@REALdavidmiscarriage I know a bunch of people who've been homeschooled too. They've been socially capable, intelligent, mentally healthy (in one case, far more so than when they were in public school), and completely educated - potentially more so than their peers. They started homeschooling by mutual consent with their parents. Anecdotes don't prove anything here.
While I personally wouldn't want to be homeschooled or to homeschool myself, there are some people who thrive in that kind of system.
@@berylliosis5250 No shit. you just proved my point, exceptions prove the rule. Also you aren't bringing any evidence for it being as good as regular school or better. That's not how that works. You can't just say unicorns exist and ask me to disprove it. You are the one making a bold claim here in comparing homeschooling with regular schools you have to bring factual evidence but you are using anecdotes yourself. So why don't we just slow down a bit and treat this for what it is an argument based on anecdotes not some scientific research paper. Maybe 1 in 1000 students might thrive off of homeschooling. Yeah also maybe 1 in a few million people win the lottery ,so? Does that mean it is worth playing the lottery?
12:00 And if A isn't symmetric, the derivative could be represented as (A+At)x, where At is A transposed. Which also looks nice.
great point :)
You're good at this ... extremely amazing....would you mind making a video on the following:
1. Maximum Likelihood Estimation
2. GMM
3. GLS
Everyone is sleeping and I'm here watching derivatives of matrices
Relatable
'Everyone' includes all persons, presumably... that would include the observer, so this sentence is inadmissible or meaninglesss.. ps i am only a minor student of logic so I praise the observer's meaning...peace
@@doce7606 "except for me" is always implied
@@danielchmiel7787 not to a nit-picking logician, which normally I'm not, lol, i had just been reading Quine..
@@doce7606 "everyone" makes no statement about the one who said it
amazing, love the energy.
Thank you!
One question: why the derivative of the second example is a column vector? (9:35) I thought it was a row vector, similar to the form in 3:38 (the first row: [df/dx1 df/dx2]. A great video! (It is the same problem as Ravi Shankar’s two months ago)
me too
I think you are correct, at 10:23 he does say that "if you had 3 different functions and 4 different variables you would have a 3 by 4 matrix, i.e. 3 rows and 4 columns". And the result would be 2*xt*A
Me too! I think it should be a row vector, and this pushed me to go back to see the video again
same! is there any answer?? was the instructor wrong?
yeah hes mixing numerator and denominator layout :/, in numerator layout a vector function by a scalar is a column vector, a scalar function by a vector is a row vector. In denominator layout a vector function by a scalar is a row vector and a scalar function by a vector is a column vector. (*By = derivatve with respect to)
So it’s basically a weird notation for a Jacobian?
I was thinking the same thing
@@ramakrishnaamitr10 even though he doesn't write them fancy, with how he does the math it looks like these are partial derivatives.
@@ramakrishnaamitr10 he isn't using the appropriate symbol, but he is indeed performing partial derivatives
Okay, so he looks at the function x -> Ax. This is a linear transformation, and the jacobian of any linear transformation is the linear transformation itself. This makes sense because you can think of the Jacobian as the best linear approximation for any function between R^n and R^m, whether it be linear or not.
Now, in some sense, yes you can say that the derivative of the matrix is the Jacobian, because a matrix, after all, represents a linear function. As already stated, the derivative of a linear function is basically the Jacobian.
I think the moral of this video is that it is best to actually think in terms of function from R^n -> R^m, (vector-valued functions)
Does this clarify things?
@Aletak 13 yeah, the Jacobian represents a local linear transformation, which describes how much you are stretching or squishing space. The determinant of the transformation gives you what the area is scaled by, which is why it comes up when you change variables :)
I got this randomly from UA-cam’s algorithm, and I’m gonna give this man a follow! I’m a math major
in like the first week or something? you see there is some weird shit going on right?
@Roman Koval everything is probability
@Roman Koval literally the very existence of an electron in a place in space is a probability, and electrons are building blocks for literally every material object
You are an absolute life-saver! I am a transfer student studying chemical engineering at UC Davis and your videos match up perfectly with what we are taught :) You have helped tremendously and have given me the knowledge to solve my overly complicated problem sets. Keep making videos and I'm certain you've helped many others as well. Brilliant instructor.
are you still studying chem eng?
this video just saved me!!! Exactly what I need for my Econometrics assignment!
lol same
The derivative of Ax is A^T
You are a wizard, thanks.
I've watched the video 3 times and picked up few things that I didn't in the first time. I'm a little slow though.
ua-cam.com/video/XQIbn27dOjE/v-deo.html 💐💐
You are really good at what you do (i.e. making this simple and understandable). Hats off to you.
When you calculated the derivative of A over the vector x you add the partial derivatives of the function f1 and f2 as row vectors in the matrix. Then, when you calculated the gradient of f1 = x^{T}Ax then over x the results was a column vector. Shouldn't be in this case the first result A^{T}?
same thought bro
Super easy to follow along and clearly explained, thank you!
Glad it was helpful!
Chandrashekar would be proud. I'm learning. Thanks
Some advice:
The kids that need this video most have likely learned about gradients. They may have heard of this concept as a 'hyper-gradient,' which is a less common way they can be taught in some schools. In either case, I've found that introducing it to them as a stack of gradients, one of f1 and one of f2, can help a lot. This puts things in terms that many kids would have already learned.
Also, it may help to determine the ideal background of the viewers your targeting before making the video, just to crystallize the constraints you should be working with in making this video. If you do this, it's not apparent, and maybe identifying the ideal background explicitly can help.
Finally, many concepts, especially differential operators like derivatives, may have other names. In this case, Jacobian is an obvious one. Listing these aliases may help students that need additional resources.
love the detailed feedback, thanks so much!
12:48 the derivative is equal to 2Ax only when A is symetric, that is, A=A^T. The more general derivative is (A+A^T)x.
Thanks, me from the past 😊
You're a great communicator. Go Bruins!
go Bruins!
man you deserve more spotlight. thank you from the bottom of my heart.
Absolutely love it! It was so useful to have the analogy between regular calculus and matrix calculus shown. Makes things much more intuitive.
Sure we can take the derivative of a matrix! It just depends on what the function is. In this example shown in the video the function output is a vector. But it could have also been a matrix output. In that case we would have a rank 4 matrix as the derivative assuming inputs are two 2 dimensional tensors each. The main idea is to understand what a Jacobian matrix is and then you will see how all these are various special cases of that general idea. To rephrase, yes, we don' take a derivative of just any matrix as it makes no sense in the same way it doesn't make sense to take derivative of a vector. Derivative is defined for a function. But no matter what the output of a function is, be it scalar, vector, tensor or matrix, there is always a way to define its derivative.
A matrix inherently has discrete, integral indices, so it can't be differentiated, but you can differentiate a function whose coefficients are expressed by a matrix
I'd even go further and just say that you can identify a matrix with a vector in R^{nm} and use the idea of the Jacobian matrix like you talk about. I don't think it is necessary to go into the idea of rank unless you specifically care about tensor calculus.
Even still, In that case, it is still basically vectors, except you might be taking tensor products with elements in the dual space.
I absolutely agree that the main idea is to understand what a Jacobian matrix is
@@astrobullivant5908 The fact that the indices are discrete doesn't matter- a vector also has discrete indices! You don't differentiate with respect to the index number, but with respect to whatever variable each component depends on. If the matrix is constant, like [ 1 2 ; 3 4], then the derivative would just be the zero matrix.
@@seanki98 You're right, I'm wrong.
Thanks for all your work ritvik! Especially explaining things with a PURPOSE, not just math porn with no applications in real world.
ua-cam.com/video/XQIbn27dOjE/v-deo.html 💐💐
Came here looking for LOWESS algorithm, and it turns out that the the derivative of xTAx plays a role in it. You helped me understand what matrix derivation is, plus solved my very particular need. Thanks.
Great video, you have way with drilling the concept into people's heads. Just awesome.
I appreciate that!
Who are the 226 people who didn't like the video? Maybe the ones who didn't understand why the derivative of kx = k, and the derivative of kx^2 is 2kx. This is mind-blowingly intuitive. I've never heard a matrix being called a bunch of scalars in a box. All the videos made by ritvikmath are excellent videos. Although I have used Eigenvalues, Eigenvectors, and derivatives of linear combinations extensively, it never made this kind of intuitive sense.
This channel is what we ALL needed, its great ur a genius. Should be a uni lecturer
13:15 Think of rearranging k*x^2 as x^T*k*x since x is a scalar. That is just the analog of quadratic form of x^T*A*x
Indeed :) - I've always thought of x^T*k*x as the vector form of quadratic too.
Nice!
You are the man. I really appreciate your clear explanations.
superb! .... Everyone is sleeping and I'm here watching derivatives of matrices
Actually, the calculations for \frac{\mathrm{d} Ax}{\mathrm{d} x} you use the numerator-layout notation and the result is A, but when you compute \frac{\mathrm{d} x^T Ax}{\mathrm{d} x}, you use the denominator-layout notation which the result is 2Ax, and if you use the numerator-layout notation, the result should be 2 x^T X.
Reference:
en.wikipedia.org/wiki/Matrix_calculus
I found the same thing. xTAx = 2xTA instead of 2Ax. The difference is the result is a row vector instead of a column vector. I also used the same wikipedia resource for definitions.
@@tissuewizardiv5982 Agreed.
It is very helpful!
I am learning linear model.
But I am not familiar with derivatives of matries.
Thank you!
This is astonishingly easy to follow.
Def look into becoming a professor. Thanks for the vids.
Thank you!
Interesting. I never learn this stuff from colleague nor it introduce it before.
ua-cam.com/video/XQIbn27dOjE/v-deo.html 💐💐
I love your energy in what you are doing.
I cheer for you and thank you for making great contents!
I appreciate that!
Dude I just wanted to let you know that your explanation is very intuitive and noice
thanks!
Close your eyes and you'll hear Russel Peters explaining matrix derivatives.
ua-cam.com/video/XQIbn27dOjE/v-deo.html 💐💐
Suppose 2×2 matrix=A has a characteristic polynomial = C.P(A) = λ² - bλ + c
then dƒ/dλ = 2λ - b
Cayley Hamilton: A² - b•A + c•I
means dƒ/dA = 2A - b•A
which looks an awful lot like 2λ - bλ
Oh, that doesn't mean anything I'm just using power rule with A & λ instead of x.... right?
Well what is rhe definition of a derivative?
lim [ (ƒ(x+Δx)-ƒ(x))/Δx] = dƒ/dx
Δx→0
What about this?
lim [ (ƒ(λ+Δθ)-ƒ(λ))/Δλ] = dƒ/dλ?
Δλ→0
What about this?
lim [ (ƒ(A+ΔA)-ƒ(A))/ΔA] =dƒ/dA ?
ΔA→0
Ok, fine Im doing the same thing again with limits now. but suppose you define a 2×2 matrix=A with actual numbers and then you say ƒ[A] = A² = AA
and you speculate dƒ/dA = d/dA[A²] =2A
Right???
I mean you actually write entries in the matrix in
this limit below s.t.
I = Identity matrix
only instead of this:
lim [ (ƒ(A+ΔA)-ƒ(A))/ΔA]
ΔA→0
you cant ÷ a matrix, so you do this
lim [ ((A+ΔAI)² -A²)(ΔA)⁻¹ ] =
ΔA→0
lim [ A² + 2ΔAI + (ΔAI)² -A² (ΔA)⁻¹ ]
ΔA→0
ΔAI = ΔA•Identity matrix =
[ΔΑ 0]
[0 ΔΑ] = ΔΑΙ
(ΔΑΙ)⁻¹ = (1/det(ΔΑΙ))•adj(ΔΑΙ)=
[1/ΔΑ 0 ]
[ 0 1/ΔΑ] = (ΔΑΙ)⁻¹
We can get 2A.... right?
Or is it, as you say, just like taking the derivative of a constant?
(I leave this as an exercise for the reader to verify.)
Just playing... I'M DOING THIS!! NO CONSTANT, BABY!!
e.g.
Claim:
It is possible to take the derivative of at least one 2×2 matrix = A s.t. ƒ[A] = A²
& d/dA [A²] = 2A according to "the limit definition of a derivative" and the definition of a function, ƒ.
Proof of Claim:
Let
[ 1 1]
[ 0 2] = A
[ 1 3 ]
[ 0 4 ] =A²
[ 2 2 ]
[ 0 4 ] = 2A
[1/ΔΑ 0 ]
[ 0 1/ΔΑ] = (ΔΑΙ)⁻¹
lim [ A² + 2ΔAI + (ΔAI)² -A² (ΔA)⁻¹ ]
ΔA→0
lim [ A² + 2ΔAI + (ΔAI)² -A² (ΔA)⁻¹ ]
ΔA→0
oh, look at that boy!!
wait until that s**t cancels out
(I kneew they wouldn't line up, but you see it!!)
[1/ΔΑ 0]• ([1 3]+[2 2]+[ΔΑ 0]+[(ΔΑ)²0]-[1 3])
[0 1/ΔΑ] ([0 4] [0 4] [0 ΔΑ] [0(ΔΑ)²] [0 4])
as lim ΔA→0
Look at A² & -A²
gone! canceled
[1/ΔΑ 0]• ([2 2]+[ΔΑ 0]+[(ΔΑ)²0])
[0 1/ΔΑ] ([0 4] [0 ΔΑ] [0(ΔΑ)²])
as lim ΔA→0
now add those 3 matrices
[1/ΔΑ 0][2+ΔΑ+(ΔΑ)² 2ΔΑ]
[0 1/ΔΑ][ 0 4ΔΑ+(ΔΑ)²]
as lim ΔA→0
Multiply
[1/ΔΑ 0][2ΔΑ+(ΔΑ)² 2ΔΑ]
[0 1/ΔΑ][ 0 4ΔΑ+(ΔΑ)²]
as lim ΔA→0
=
[(2ΔΑ+(ΔΑ)²)/ΔΑ 2ΔΑ/ΔΑ]
[ 0/ΔΑ (4ΔΑ+(ΔΑ)²)/ΔΑ]
as lim ΔA→0
=
[(2+ΔΑ 2]
[ 0 4+(ΔΑ)] as lim ΔA→0
=
[(2+0 2]
[ 0 4+0] =
[ 2 2 ]
[ 0 4 ] = 2A = d/dA[A²]
therefore,
it is possible to take the derivative of at least one 2×2 matrix = A s.t. ƒ[A] = A²
& d/dA [A²] = 2A according to
"the limit definition of a derivative"
and the definition of a function, ƒ. ■
edit : I knew these wouldn't all line up, lol
Wha-what did you do?
I have a question, in the first derivative d(Ax)/dx, why should we do it in row, while d(x'Ax)/dx, we do it in column? Thank you
Same question for this...
Hmm... Good question. I didn't notice that before I read your comment. It could because of the x' present at the beginning of x'Ax. I'm not sure though.
That's exactly what I thought.
Maybe he is writing the d(Ax)/dx in matrix notation while d(x^(T)Ax)/dx in vector notation? He does use square brackets for the former and parentheses for the latter, but I'm not too sure myself.
Because there's a difference between X and the transpose of X. X is a column vector and so X transpose is a row vector.
you just saved me Econometrics student from Korea ; Thx a lot
Time to reward yourself with some Milkis, kimichi, and of course, gangnam style.
exactly what i was looking for !
At@ 9:41, could you tell me why you took a column vector and not a row vector? Is it a rule that we should take it as a column vector ? How to know what would be the shape of the matrix or vector?
Wonderful
Amazing skills to clear students doubt
ua-cam.com/video/XQIbn27dOjE/v-deo.html 💐💐💐
Excellently explained
Wow. Excellent video. Thanks!
Glad you liked it!
You are just AMAZING !! So clear and easy to get!
ritvikmath up next just waitin for people to stop sleepin on him
great video:) you're really good at explaining. Thank you very much!!
You're very welcome!
thanks for the video! i recommend manual focus on the whiteboard, if possible though!
Thanks for the tip! I've fixed this in my more recent videos thanks to suggestions like yours :)
Great job clearing up this topic.
This video helped me a lot! Love your energy, keep 'em coming!
Thank you! Will do!
Wow, that was a brilliant video! I really like the teaching style. +1 Subscriber
Awesome, thank you!
an incredible easy to follow class, thanks a lot!
At 10:25 you said for 3 different functions and 4 different variables you'd have a 3x4 matrix. But the one you solved above only had 1 function and 2 variables x1 and x2. Why then did you create a 2x1 matrix instead of a 1x2?
Great video, thanks for sharing
This video is a prime example of the state of Artificial Intelligence and Data Science at the moment: many in the field don't know what they are talking about, especially the maths part of it.
The title is misleading. Nowhere in the video, you compute the derivative of a matrix (as shown in the video thumbnail). You compute the derivative of a vector wrt another vector, and as the result, you get the matrix.
thanks
Excellent! I was looking for the explanation of derivative of linear transformation for a long time!
ua-cam.com/video/XQIbn27dOjE/v-deo.html 💐💐
You are a great teacher!
Aw thank you :)
You are awesome!!!! Thanks you!
You're welcome!
Really useful video. Thanks
Thanks for your awesome video!
great.especially with
transpose(x)Ax
Any matrix can be broken into sum of a symmetric and an anti-symmetric matrix. Now you know the derivative of the symmetric one. Find the derivative of the asymmetric one and you have a recipe for finding the derivative of any general matrix.
Good point!
@@ritvikmath I texted you on linkedin, do check
This video is really helpful! Thanks for making this concept so clear!!!
dayyyyyyyyyum. So nicely explained. Thank you!
Your teaching quotient is very high.
Math is so cool! I half suck at linear algebra but seeing all the crazy stuff you can do with it makes me want to go back and learn it really well.
Brilliant, thank you!
You're very welcome!
Your concept is very clear and agood teacher
With the xT A x case, we can let A be symmetric without loss of generality. If not, replace aij and aji with their mean, you get the exact same function.
In fact you would not get that derivative to be 2Ax if A wasn't symmetric
He didn't say "let A be symmetric without loss of generality". Instead, he said that he will only focus on the case when A is symmetric because that is the case which we care about and can apply to "principal component analysis"
@@seanki98 I think you didn't understand what I'm saying.
I mean, it is a FACT the A can be assumed symmetric without loss of generality. Thus, only considering the symmetric case invokes NO LOSS OF INFORMATION.
for each square matrix A, define f_A(x) = x^T A x.
it hold that "for all" such A, symmetric or not, "there exists" symmetric B, so that f_A, and f_B are identical functions. In fact B=(1/2)(A^T+A).
DO YOU UNDERSTAND NOW YOU DUMB DIMWIT?
94mathdude That is cool to learn that A can be replaced with a symmetric matrix without loss of generality. Thanks a lot!
@@Grassmpl Pretty sure there's only one DUMB DIMWIT here, and it certainly isn't Sean. Oh, wait, I'm here too, that makes two.
Seriously, man, insulting somebody for not automatically understanding your poorly-worded and difficult-to-read comment isn't cool.
Man this video went into quadratic Forms out of nowhere, but it makes sense since I'm here for an optimization course
Thank you! This video really cleared things up for me :)
I'm so glad!
great explanation! Thanks a lot
You are welcome!
Hi RItwik! One doubt ---> At 9:04 of the video, shouldn't the resultant matrix be 1*2 and not 2*1 as we are multiplying 1*2 and 2*2, so result should be 1*2 and not 2*1?. Please correct me if I am wrong. A fan of your videos!
i think u are right.i have same question.
It's easy to understand!!!Thank you
ua-cam.com/video/XQIbn27dOjE/v-deo.html 💐💐
Thanks, very good video. helped me in understanding everything
You are great ! great video, great representation, Thanks!
ua-cam.com/video/XQIbn27dOjE/v-deo.html 💐💐
very easy to understand and thank you very much!
ua-cam.com/video/XQIbn27dOjE/v-deo.html 💐💐💐
Man i searched for you everywhere and a recommendation send me here.
ua-cam.com/video/XQIbn27dOjE/v-deo.html 💐💐
Very clearly explained.Subscribed.Thanks
I wanted to here you talk of the statement "partial differentiation"
This is awesome!! 👍
Great job, thanks a lot from italy. Keep up the good work ;)
Wow all the way from Italy! Thank you :)
Excellent video, thank you!
really good
god thanks very much, really an awesome work
This means some diagonalisation of amplitude split-up merged by a third interactive may a transpose double the amplitude by a third interactive.Every crystal by interaction split-up the ampiltude by a phase difference interacted by a transpose dynamics of third interactive may produce twice the amplitude as obeserved by symmetry.
Sankaravelyudhan Nandakumar.
That is not the derivative of a matrix, but the derivative of a matrix product. Just like d/dx 3x = 3 is not the derivative of the number 3.
Dave Langers which is what he says at 4:30
@@michaelseery5588 Yeah, but that title...
Understood very good Tq u sir
great vid, thanks
ua-cam.com/video/XQIbn27dOjE/v-deo.html 💐💐💐
this is so awesome.
BRAVO! This explanation has helped me tremendously...THANK YOU!!
This is the first time I have seen this, even though I am a post grad physics grad. Thanks!
with just any A we will get xT(A+At)
A+At is symmetric matrix
Actually this reminded me of my university days I cramed this so badly😟
In week one of a numerical optimization course, the professor wanted a proof of the d/dv (vT A v)=2Av where v is an n-dimensional vector. This video is the trivial case of a 2D vector.
Basically, the same proof works though.
clap!!! I like it
Sorry if my question is lame but at 10:24 you say that "If you have 3 different functions and 4 different variables, you have 3X4 matrix." Since we have 1 function and 2 different variables in the example, why don't we have 1X2 matrix instead of 2X1 matrix?
Amazing video. Thanks man. Subscribed right away.