diff --git a/owlps-positioner/src/posutil.cc b/owlps-positioner/src/posutil.cc index 41c371e..02b5ff4 100644 --- a/owlps-positioner/src/posutil.cc +++ b/owlps-positioner/src/posutil.cc @@ -73,11 +73,19 @@ void PosUtil::complete_with_dummy_measurements( * Both lists must have the same size and contain the same keys: * you should call complete_with_dummy_measurements() before * compute_ss_square_distance(). + * + * The distance between the two lists is computed by averaging the + * square distances between the elements of both lists, two by two. + * Therefore, it is not really an averaged square distance; you cannot + * divide it to obtain an euclidean distance. To do that, one would + * have to create a ss_distance() function that average the distances + * between the elements of the lists instead of the square distance. */ float PosUtil::ss_square_distance( unordered_map &measurements1, unordered_map &measurements2) { + assert(! measurements1.empty()) ; assert(measurements1.size() == measurements2.size()) ; float distance = 0 ; @@ -88,11 +96,10 @@ float PosUtil::ss_square_distance( unordered_map::const_iterator i2 = measurements2.find(i1->first) ; assert(i2 != measurements2.end()) ; - distance += i1->second.ss_square_distance( - i2->second) ; + distance += i1->second.ss_square_distance(i2->second) ; } - return distance ; + return distance / measurements1.size() ; }