<div dir="ltr"><div>Virgil's absolutely right. Median as the "middle" value in a _sorted_ set is:</div><div>- for odd number of data points, it's the middle one: set[N/2]</div><div>- for even number of data points, it's the average of two in the middle: (set[N/2] + set[(N+1)/2]) / 2</div><div> </div><div>Best regards,</div><div>Maciej</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 11, 2015 at 3:44 PM, Virgil Griffith <span dir="ltr"><<a href="mailto:i@virgil.gr" target="_blank">i@virgil.gr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><span style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px">I mean the median.</span><span style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px"><br></span></div><div><span style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px"><br></span></div><div><span style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px">From Wikipedia...</span></div><div><span style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px"><br></span></div><div><span style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px">For example, if </span><i style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px">a</i><span style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px"> < </span><i style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px">b</i><span style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px"> < </span><i style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px">c</i><span style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px">, then the median of the list {</span><i style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px">a</i><span style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px">, </span><i style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px">b</i><span style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px">, </span><i style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px">c</i><span style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px">} is </span><i style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px">b</i><span style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px">, and, if </span><i style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px">a</i><span style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px"> < </span><i style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px">b</i><span style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px"> < </span><i style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px">c</i><span style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px"> < </span><i style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px">d</i><span style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px">, then the median of the list {</span><i style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px">a</i><span style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px">, </span><i style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px">b</i><span style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px">, </span><i style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px">c</i><span style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px">, </span><i style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px">d</i><span style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px">} is the mean of </span><i style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px">b</i><span style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px"> and </span><i style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px">c</i><span style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px">; i.e., it is (</span><i style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px">b</i><span style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px"> + </span><i style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px">c</i><span style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px">) / 2.</span></div><span class="HOEnZb"><font color="#888888"><div><span style="color:rgb(37,37,37);line-height:20.36px;font-family:sans-serif;font-size:14px"><br></span></div><div>-V</div></font></span></div><div class="HOEnZb"><div class="h5"><br><div class="gmail_quote"><div dir="ltr">On Tue, Aug 11, 2015 at 9:29 PM John <<a href="mailto:oneofthem@riseup.net" target="_blank">oneofthem@riseup.net</a>> wrote:<br></div><blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid" class="gmail_quote">I think you are confusing the median with the mean:<br>
<br>
<a href="https://en.wikipedia.org/wiki/Median" rel="noreferrer" target="_blank">https://en.wikipedia.org/wiki/Median</a><br>
<a href="https://en.wikipedia.org/wiki/Mean" rel="noreferrer" target="_blank">https://en.wikipedia.org/wiki/Mean</a><br>
<br>
Taking the median instead of the mean can be beneficial in situations<br>
where you have larger outliers in your data, which typically affect the<br>
mean very much.<br>
<br>
-j<br>
<br>
Virgil Griffith:<br>
> Is there some implementation-specific reason not to use the standard<br>
> mathematical definition of "median"?  If not, I propose changing the<br>
> implementation to become it.<br>
><br>
> -V<br>
><br>
> On Tue, Aug 11, 2015 at 2:44 AM Nick Mathewson <<a href="mailto:nickm@alum.mit.edu" target="_blank">nickm@alum.mit.edu</a>> wrote:<br>
><br>
>> On Mon, Aug 10, 2015 at 1:11 PM, nusenu <<a href="mailto:nusenu@openmailbox.org" target="_blank">nusenu@openmailbox.org</a>> wrote:<br>
>>> -----BEGIN PGP SIGNED MESSAGE-----<br>
>>> Hash: SHA512<br>
>>><br>
>>> Hi,<br>
>>><br>
>>> <a href="https://gitweb.torproject.org/torspec.git/tree/dir-spec.txt#n2028" rel="noreferrer" target="_blank">https://gitweb.torproject.org/torspec.git/tree/dir-spec.txt#n2028</a><br>
>>><br>
>>>> If 3 or more authorities provide a Measured= keyword for a router,<br>
>>>> the authorities produce a consensus containing a "w" Bandwidth=<br>
>>>> keyword equal to the median of the Measured= votes.<br>
>>><br>
>>> a random sample from recent votes:<br>
>>><br>
>>> grep 37.59.38.117 -A 3 *|grep Measured<br>
>>> w Bandwidth=6869 Measured=7570<br>
>>> w Bandwidth=6869 Measured=15500<br>
>>> w Bandwidth=6869 Measured=18100<br>
>>> w Bandwidth=6869 Measured=30500<br>
>>><br>
>>> Tor says the median value is<br>
>>> 15500<br>
>>><br>
>>> 2015-08-10-16-00-00-consensus:<br>
>>> w Bandwidth=15500<br>
>>><br>
>>> but the median of these 4 values is actually:<br>
>>> (18100+15500)/2 = 16800<br>
>>> no?<br>
>>><br>
>>> Has tor a different definition of 'median' and simply takes always the<br>
>>> second ordered measurement vote out of 4 votes or is there a bug in<br>
>>> the spec or implementation?<br>
>><br>
>> There's one misplaced throwaway sentence in dir-spec.txt:<br>
>><br>
>> "  All ties in computing medians are broken in favor of the smaller or<br>
>>    earlier item.<br>
>> "<br>
>><br>
>> We should bring this, and probably other things, into a "definitions"<br>
>> section earlier in dir-spec.txt.  Patches welcome. ;)<br>
>><br>
>> --<br>
>> Nick<br>
>> _______________________________________________<br>
>> tor-dev mailing list<br>
>> <a href="mailto:tor-dev@lists.torproject.org" target="_blank">tor-dev@lists.torproject.org</a><br>
>> <a href="https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-dev" rel="noreferrer" target="_blank">https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-dev</a><br>
>><br>
><br>
><br>
><br>
> _______________________________________________<br>
> tor-dev mailing list<br>
> <a href="mailto:tor-dev@lists.torproject.org" target="_blank">tor-dev@lists.torproject.org</a><br>
> <a href="https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-dev" rel="noreferrer" target="_blank">https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-dev</a><br>
><br>
_______________________________________________<br>
tor-dev mailing list<br>
<a href="mailto:tor-dev@lists.torproject.org" target="_blank">tor-dev@lists.torproject.org</a><br>
<a href="https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-dev" rel="noreferrer" target="_blank">https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-dev</a><br>
</blockquote></div>
</div></div><br>_______________________________________________<br>
tor-dev mailing list<br>
<a href="mailto:tor-dev@lists.torproject.org">tor-dev@lists.torproject.org</a><br>
<a href="https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-dev" rel="noreferrer" target="_blank">https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-dev</a><br>
<br></blockquote></div><br></div>