Let the hyperplane equation be $\theta^Tx + \theta_0 = 0.$ Let p be any point. Find the signed perpendicular distance between the point and the hyperplane. (Answer in terms of $\theta^Tx$, $\theta_0$, and $p$; you may not answer using $x$)
My attempt:
$$(p-x)*\theta^T*(\frac1{len\theta^T})$$
Then I distribute the $\theta^T$:
$$ p*\theta^T – x*\theta^T*(\frac1{len\theta^T})$$
The middle term can be re-written as $\theta_0$ from the equation we of the hyperplane.
We'll end up with $$ p*\theta^T + \theta_0*(\frac1{len\theta^T})$$
(Btw, $len\theta^T$ is the lengths of $\theta^T$)
Best Answer
Geometrically $\theta$ is a normal vector to the hyperplane $H$. Then we must draw a line $l$ from $p$ in the direction of $\theta$ and compute the distance between $p$ and $q \in l\cap H$.
Every point in $l$ is written as $p+ t\theta$ for some $t\in \mathbb{R}$. To find the point of intersection with $H$ we just set the equation $$ 0 = \theta^T( p + t\theta) + \theta_0 = \theta^T\cdot p + t\theta^T\cdot \theta + \theta_0 $$ Solving for $t$ we get $t = \frac{-\theta_0 - \theta^T\cdot p}{\|\theta\|^2}$. Hence $$ q = p + \frac{-\theta_0 - \theta^T\cdot p}{\|\theta\|^2}\theta $$ Now we head to the signed distance. We have that $$(p-q)^T\cdot \frac{\theta}{\|\theta\|} = \frac{\theta_0 + \theta^T\cdot p}{\|\theta\|}$$ Note that $$ \|q-p\| = \left\| \frac{-\theta_0 - \theta^T\cdot p}{\|\theta\|^2}\theta \right\| = \frac{|\theta_0 + \theta^T\cdot p|}{\|\theta\|} $$ which is the absolute value of the signed distance.