Is there some implementation-specific reason not to use the standard mathematical definition of "median"?  If not, I propose changing the implementation to become it.

-V

On Tue, Aug 11, 2015 at 2:44 AM Nick Mathewson <nickm@alum.mit.edu> wrote:
On Mon, Aug 10, 2015 at 1:11 PM, nusenu <nusenu@openmailbox.org> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA512
>
> Hi,
>
> https://gitweb.torproject.org/torspec.git/tree/dir-spec.txt#n2028
>
>> If 3 or more authorities provide a Measured= keyword for a router,
>> the authorities produce a consensus containing a "w" Bandwidth=
>> keyword equal to the median of the Measured= votes.
>
> a random sample from recent votes:
>
> grep 37.59.38.117 -A 3 *|grep Measured
> w Bandwidth=6869 Measured=7570
> w Bandwidth=6869 Measured=15500
> w Bandwidth=6869 Measured=18100
> w Bandwidth=6869 Measured=30500
>
> Tor says the median value is
> 15500
>
> 2015-08-10-16-00-00-consensus:
> w Bandwidth=15500
>
> but the median of these 4 values is actually:
> (18100+15500)/2 = 16800
> no?
>
> Has tor a different definition of 'median' and simply takes always the
> second ordered measurement vote out of 4 votes or is there a bug in
> the spec or implementation?

There's one misplaced throwaway sentence in dir-spec.txt:

"  All ties in computing medians are broken in favor of the smaller or
   earlier item.
"

We should bring this, and probably other things, into a "definitions"
section earlier in dir-spec.txt.  Patches welcome. ;)

--
Nick
_______________________________________________
tor-dev mailing list
tor-dev@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-dev