[Haskell-cafe] Re: Why 'round' does not just round numbers ?

wren ng thornton wren at freegeek.org
Tue Oct 28 13:05:14 EDT 2008

Bart Massey wrote:
> Peter Gavin <pgavin <at> gmail.com> writes:
>> The reason for doing it this way is that e.g. 2.5 is
>> exactly between 2 and 3, and rounding *up* every time
>> would cause an uneven bias toward 3.  To counteract that
>> effect, rounding to the nearest even integer is used,
>> which causes the half of the x.5 values to round up, and
>> the other half to round down.
> Everyone keeps providing this rationale, but of course if
> you want "half the values to round up and the other half
> down" it does just as well to round positive values up and
> negative values down.

The rational is to have half of the expected distribution of 'related' 
invocations round up/down, regardless of the (adversarial) distribution 
of input value instances. The round to zero method provides this only 
when the distribution of instances are symmetric about zero. Barring 
random number generators, these are extremely uncommon distributions in 
practice. The round to even method provides this guarantee so long as 
the adversary can't choose between Even+0.5 vs Odd+0.5 values whenever 
it wants. In terms of non-adversarial distributions, this covers almost 
all of them, and in particular it is not biased to a particular mean for 
the distribution.

Granted, not everyone is trying to get as close to the correct answer as 
possible. Sometimes it's more important to guarantee one-sided error 
than it is to minimize the error margins. But, IME, the most-correct 
answer is the general goal and when people have another goal in mind 
they're quite aware of it.

Live well,

More information about the Haskell-Cafe mailing list