Reputation: 21
I'm trying to understand the normalized squared euclidean distance formula from the Wolfram documentation:
1/2*Norm[(u-Mean[u])-(v-Mean[v])]^2/(Norm[u-Mean[u]]^2+Norm[v-Mean[v]]^2)
I searched around for this formula on the web but couldn't find it. Can someone explain how this formula is derived?
Upvotes: 2
Views: 3833
Reputation: 8655
Further to Luca's comment, here is an example showing the "distance between two vectors where their lengths have been scaled to have unit norm". It doesn't equal the normalised square Euclidean distance. The former is coloured blue in the graphic below. The standard Euclidean distance is coloured red.
(* Leave this unevaluated to see symbolic expressions *)
{{a, b, c}, {d, e, f}} = {{1, 2, 3}, {3, 5, 10}};
N[EuclideanDistance[{a, b, c}, {d, e, f}]]
7.87401
Norm[{a, b, c} - {d, e, f}]
SquaredEuclideanDistance[{a, b, c}, {d, e, f}]
Norm[{a, b, c} - {d, e, f}]^2
N[NormalizedSquaredEuclideanDistance[{a, b, c}, {d, e, f}]]
0.25
(1/2 Norm[({a, b, c} - Mean[{a, b, c}]) - ({d, e, f} - Mean[{d, e, f}])]^2)/
(Norm[{a, b, c} - Mean[{a, b, c}]]^2 + Norm[{d, e, f} - Mean[{d, e, f}]]^2)
1/2 Variance[{a, b, c} - {d, e, f}]/(Variance[{a, b, c}] + Variance[{d, e, f}])
{a2, b2, c2} = Normalize[{a, b, c}];
{d2, e2, f2} = Normalize[{d, e, f}];
N[EuclideanDistance[{a2, b2, c2}, {d2, e2, f2}]]
0.120185
Graphics3D[{Line[{{0, 0, 0}, {1, 2, 3}}],
Line[{{0, 0, 0}, {3, 5, 10}}],
Red, Thick, Line[{{1, 2, 3}, {3, 5, 10}}],
Blue, Line[{{a2, b2, c2}, {d2, e2, f2}}]},
Axes -> True, AspectRatio -> 1,
PlotRange -> {{0, 10}, {0, 10}, {0, 10}},
AxesLabel -> Map[Style[#, Bold, 16] &, {"x", "y", "z"}],
AxesEdge -> {{-1, -1}, {-1, -1}, {-1, -1}},
ViewPoint -> {1.275, -2.433, -1.975},
ViewVertical -> {0.551, -0.778, 0.302}]
Upvotes: 1
Reputation: 8677
Meaning of this formula is the following:
Distance between two vectors where there lengths have been scaled to have unit norm. This is helpful when the direction of the vector is meaningful but the magnitude is not.
https://stats.stackexchange.com/questions/136232/definition-of-normalized-euclidean-distance
Upvotes: 2