Suppose I have 4 vectors, the first 2 vectors are of length 4 and the last 2 vectors are of length 400. all values in the vectors range from 0.5 to 0.6.

The Euclidean distance between the last 2 vectors will be greater than the distance between the first 2 vectors. This is due to the much larger dimensionality of the last 2 vectors.

How can I modify my approach to make both the distance values comparable ? I have thought of using Cosine or Jaccard distance, but I do not want the similarity/angle between the vectors.

Could I simply divide each distance by the length of the vectors ?

So the new distance d1 would be:

d1 = d1/4

and the new distance d2 would be:

d2 = d2/400

Would this approach be an effective way to compute the Euclidean distance between data where the scale of each value is the not skewed, but the length of the pair of vectors between which the distance is measured is not uniform ?


1 Answer 1


You should divide by the square root of the length of the vector.

Given a random vector $v$ (the difference between your two vectors) with $n$ i.i.d. components $v_i\sim X$, you have that $\mathbb E[|v|^2]=\sum_i \mathbb E[v_i^2]=n \mathbb E [X^2]$.

That is, the expectation of the distance squared increases linearly with $n$, so if you want something comparable, you should divide the distance by $\sqrt n$.

  • $\begingroup$ Why does the expectation of the variable's nature matter if I am modifying my approach to find the euclidean distance per data point within the random variable ? $\endgroup$ Aug 16, 2023 at 13:46
  • $\begingroup$ The point is that distance squared increases linearly with dimension. The difference between two random vectors is a random vector and normalizing for standard deviation is a standard way to compare different things. $\endgroup$
    – Eric
    Aug 16, 2023 at 20:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .