# How to reach Moore-Penrose pseudoinverse solution to minimize error function

Edit

I'm trying to figure the derivation of the Moore-Penrose pseudoinverse for linear regression. The starting expression is the standard error function. I'm not quite sure how to expand on this since all the terms are vectors (my linear algebra is a bit rusty):

$\frac12 (\sum_{n=1}^N(w^Tx^{(n)} - t^{(n)})^2)$

where x is data vector, w is weight vector and t is target vector. So this is the error function taken over the N sample datapoints. Each datapoint consists of a vector of parameters, which is the vector $x$

I need to take the gradient of this w.r.t to $w$ to get:

$X^TXw - X^Tt$

I should clarify that $X$ here is the matrix of all $x^{(n)}$. So its an NxM matrix where N is the total datapoints and M is the number of features in each datapoint.

The Moore-Penrose pseudoinverse could then be used to minimize this function by setting the gradient at 0:

$X^TXw - X^Tt = 0$

$w = (X^TX)^{-1}X^Tt$

Can someone please explain how to do this?

• Sorry, both $x$ and $w$ are vectors? Then isn't $x^T w$ a number? – Muphrid Jan 25 '15 at 5:31
• Interesting... maybe I reached the expression incorrectly. I've updated my original post with the starting error function. I need to get the final expression by taking the derivative of this function w.r.t $w$. I'm not sure exactly how to go about doing this – user3425451 Jan 25 '15 at 5:44
• Okay, $X$ is a matrix, $X^T X$ is $m\times m$, so $w$ has $m$ elements, and $t$ has $n$ elements? – Muphrid Jan 25 '15 at 6:22
• Yes. That seems to be correct. – user3425451 Jan 25 '15 at 6:43
• You have an expression for the pseudoinverse solution. What is the question now? – Algebraic Pavel Jan 25 '15 at 11:38