Hi list,

On LocationManager#shouldSwap(), I wonder if we should use a geometric
mean instead of just multiplying them together.
Let's see the current implement:

 748         double A = 1.0;
 749         for(int i=0;i<friendLocs.length;i++) {
 750             if(Math.abs(friendLocs[i] - myLoc) <=
Double.MIN_VALUE*2) continue;

#1. some friends are skipped.
     this number should be small -- my friends shouldn't be sooo close to me.
     rare, but not impossible (?)

 751             A *= Location.distance(friendLocs[i], myLoc);
 752         }
 753         for(int i=0;i<hisFriendLocs.length;i++) {
 754             if(Math.abs(hisFriendLocs[i] - hisLoc) <=
Double.MIN_VALUE*2) continue;

#2. again some friends are skipped. (same as #1)

 755             A *= Location.distance(hisFriendLocs[i], hisLoc);
 756         }
 757
 758         // B = the same, with our two values swapped
 759         double B = 1.0;
 760         for(int i=0;i<friendLocs.length;i++) {

(      never mention his number of friends may not be the same as mine
       should we use for(int i=0;i<friendLocs.length &&
;i<hisFriendLocs.length ; i++)  ? )

 761             if(Math.abs(friendLocs[i] - hisLoc) <=
Double.MIN_VALUE*2) continue;

#3. skip yet other friends...
      but this time, we compare my friend's location with his location ..
      I have him as my friend, so this is skipped _at least_ once.

      The number of friends skipped here is not the same as those in #1 and #3..
       i.e.  A and B are calculated using different number of samples.

       as Location.distance() < 1.0 ,  the more round you multiply,
the less the value.


 762             B *= Location.distance(friendLocs[i], hisLoc);
 763         }
 764         for(int i=0;i<hisFriendLocs.length;i++) {
 765             if(Math.abs(hisFriendLocs[i] - myLoc) <=
Double.MIN_VALUE*2) continue;
 766             B *= Location.distance(hisFriendLocs[i], myLoc);
 767         }

[...]

 771         if(A>B) return true;

#4   And now, we compare A and B. This is unfair!


Regards,
Daniel Cheng

Reply via email to