Calculate Euclidean distance between 4-dimensional vectors

前端 未结 2 1464
广开言路
广开言路 2021-02-05 20:52

Let\'s say I have two 4-dimensional vectors (i.e. a and b) as follows:

a = {a1, a2, a3, a4}
b= {b1, b2, b3, b4}

How do I compute the Euclidean

2条回答
  •  难免孤独
    2021-02-05 21:08

    The euclidian distance calculus is independent of dimensions.

    In your case, the euclidian distance between a and b can be written as: d(a,b) = sqrt(sum_{i=1}^{4} (a[i] - b[i])^2).

    Or, more specifically: d(a,b) = sqrt( (a1-b1)^2 + (a2-b2)^2 + (a3-b3)^2 + (a4-b4)^2 ).

提交回复
热议问题