Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Python
Rounding a number to nearest even
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Gabriel Genellina, post: 3534250"] That's not correct. 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. That limit IS zero. And the probability of getting exactly a certain real number, or any finite set of real numbers, is zero too (assuming the usual definition of probability over infinite sets). But we're not actually talking about real numbers here. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Python
Rounding a number to nearest even
Top