Effective Euclidean distance calculation

I have an array MxN, where Mis the number of observations, and Nis the dimension of each vector. From this array of vectors I need to calculate the Euclidean distance mean, and minimumbetween the vectors.

In my understanding, this requires me to calculate the distances M C 2 , which is O (n min (k, nk) ). Mine Mis ~ 10,000 and mine Nis ~ 1000, and this calculation takes ~ 45 seconds.

Is there a more efficient way to calculate distances meanand min? Perhaps a probabilistic method? I don't need it to be accurate, just close.

+6
source share
1 answer

You did not indicate where your vectors come from, nor what you will use meanand median. Here are some general notes. Limited ranges, error tolerances, and discrete values ​​may allow a more efficient approach.

The distance meanbetween the points M sounds quadratically, O (M ^ 2). But M / N is 10, quite small, and N is huge, so the data probably resembles a hairy sphere in a 1e3 space. Computing the centroid of points M, and then calculating the distances M to the centroid, can be useful in your problem area, it’s hard to say.

minimum M . , 100, . (, , .) UB-tree, . N M x N, , min , , 1,0, .

UB-, , . . , . , , . , , PostGIS.

, (, , N = 1e3 ). , , . , , . , , , .

, . 2- , . , "" , - . N- .

0

Source: https://habr.com/ru/post/1015867/


All Articles