Calculating the Euclidean Distance
How do I calculate the Euclidean Distance between $(22, 1, 42, 10)$ and $(20, 0, 36, 8)$?
I think I know the formula, but I don't know how to apply it to this data. $$d(p, q) = \sqrt{(q_1-p_1)^2 + (q_2-p_2)^2 + \ldots + (q_n-p_n)^2}$$
I don't understand what $q_n$ or $p_n$ would point to.
$\endgroup$ 12 Answers
$\begingroup$Let $q = (q_1,q_2,q_3,q_4) = (22, 1, 42, 10)$, $p = (p_1,p_2,p_3,p_4) = (20, 0, 36, 8)$.
Then
$\sqrt{ \sum_{i=1}^4 (q_i-p_i)^2} = \sqrt{(22-20)^2+(1-0)^2+(42-36)^2+(10-8)^2}$
It might be easier to subtract the vectors first, the difference of the vectors is the vector of the differences, that is: $(22, 1, 42, 10) -(20, 0, 36, 8) = (2, 1, 6, 2)$.
Then compute the square root of the sum of the squares as in $\sqrt{2^2+1^2+6^2+2^2}= \sqrt{45}$
$\endgroup$ $\begingroup$Hint: Your two points have four entries, so $n=4$. Hence, for your first point, we have:
- $p_1 = 22$
- $p_2 = 1$
- $p_3 = 42$
- $p_4 = 10$