Rounding a number to nearest even

Arnaud Delobelle arnodel at googlemail.com
Tue Apr 15 07:14:00 EDT 2008


On 11 Apr, 21:29, Gabriel Genellina <gagsl-... at yahoo.com.ar> wrote:
> ... If the numbers to be rounded come from a
> measurement, the left column is not just a number but the representant
> of an interval (as Mikael said, the're quantized). 2.3 means that the
> measurement was closer to 2.3 than to 2.2 or 2.4 - that is, [2.25,
> 2.35) (it doesn't really matter which side is open or closed). It is
> this "interval" behavior that forces the "round-to-even-on-halves"
> rule.
> So, the numbers 1.6-2.4 on the left column cover the interval [1.55,
> 2.45) and there is no doubt that they should be rounded to 2.0 because
> all of them are closer to 2.0 than to any other integer. Similarly
> [2.55, 3.45) are all rounded to 3.
> But what to do with [2.45, 2.55), the interval represented by 2.5? We
> can assume a uniform distribution here even if the whole distribution
> is not (because we're talking of the smallest measurable range). So
> half of the time the "true value" would have been < 2.5, and we should
> round to 2. And half of the time it's > 2.5 and we should round to 3.
> Rounding always to 3 introduces a certain bias in the process.
> Rounding randomly (tossing a coin, by example) would be fair, but
> people usually prefer more deterministic approaches. If the number of
> intervals is not so small, the "round even" rule provides a way to
> choose from that two possibilities with equal probability.
> So when we round 2.5 we are actually rounding an interval which could
> be equally be rounded to 2 or to 3, and the same for 3.5, 4.5 etc. If
> the number of such intervals is big, choosing the even number helps to
> make as many rounds up as rounds down.
> If the number of such intervals is small, *any* apriori rule will
> introduce a bias.

Great explanation!

--
Arnaud



More information about the Python-list mailing list