[Positioner] Fix PosUtil::ss_square_distance()
The returned distance is now "averaged" to take into account the number of measurements in the lists. The former behaviour would lead two couples of measurement lists with a different number of measurement to have non-comparable distances.
This commit is contained in:
parent
dc0e56c0ec
commit
e687aac741
|
@ -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<string, Measurement> &measurements1,
|
||||
unordered_map<string, Measurement> &measurements2)
|
||||
{
|
||||
assert(! measurements1.empty()) ;
|
||||
assert(measurements1.size() == measurements2.size()) ;
|
||||
|
||||
float distance = 0 ;
|
||||
|
@ -88,11 +96,10 @@ float PosUtil::ss_square_distance(
|
|||
unordered_map<string, Measurement>::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() ;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue