I am watching a youtube video on Principal Component Analysis. It is written that the projection of vector $x_i$ onto vector $u_1$ is
$proj_{u_{1}}(x_i) = {u_1}^T x_i u$
where $u$ is the unit vector of $u_1$
This is slightly different from the normal projection equation.
$proj_{u_{1}}(x_i) = \frac{x_i u_1}{|| u_1|| } . u $
It seemed that the only different is ${u_1}^T$ and $\frac{u_1}{|| u_1|| }$. How is ${u_1}^T$ equivalent to $\frac{u_1}{|| u_1|| }$? Please advise thanks.
I tried with both equation but can't get some answer. Please help
import numpy as np
x1 = np.array([[1,3]])
u1 = np.array([[2,2]])
u = np.array([[2,2]]) / np.sqrt(8)
#equation 1
proj1 = u1.transpose()*x1*u
>array([[ 1.41421356, 4.24264069],
[ 1.41421356, 4.24264069]])
#equation 2
proj2 = x1*u*u
>array([[ 0.5, 1.5]])
At the begining of this video, the presenter says that as a prerequisite for this video you should watch his video on vector projections. Did you watch is video on vector projections?
https://www.youtube.com/watch?v=X78tLBY3BMk
The "normal" definition of projection as it is taught in a pre-calculus class is:
$proj_{u}(v) = \frac{u\cdot v}{|| u||^2 } u$
Where "$\cdot$" is the "dot" product (Euclidean inner product). The first factor is a scalar; the second factor is a vector. Together we have a vector that represents the component of $v$ in the direction of $u.$
Note that this is quite a bit different from what you have written as "normal."
Anyway, how do you get from $proj_{u}(v) = \frac{u\cdot v}{|| u||^2 } u$ to $proj_{u}(v) = u^Tv u$?
First, $u,v$ are column vectors. This means that $u^Tv = u\cdot v.$ Second, $u$ is defined in this video to be a unit vector, so $\|u\|= 1$ and can be ignored.