2

The standard practice for rounding numbers appears to include the "round to even" rule for cases where the digit to the right of the least significant digit is equal to 5. Here is an example from

http://www.chemteam.info/SigFigs/Rounding.html

Example #4 Round 24.8514 to three significant figures. Look at the fourth digit. It is a 5, so now you must also look at the third digit. It is 8, an even number, so you simply drop the 5 and the figures that follow it. The original number becomes 24.8. (rule #3 above)

They say that the intent of this rule it to ensure that in the long run we round up as often as we round down. If we are dealing with real numbers with infinite precision, this rule is of course unnecessary. But how about the case when we are working with floating point representations of real numbers that carry 16 or more digits of precision as would be stored internally in a computer. It seems to me that we could dispense with the round to even rule in this case with little risk of having an imbalance of round ups and round downs in the long run. Does this sound reasonable? If so, can someone offer a reference that discusses this subject and comes to the same conclusion that I did?

Thomas
  • 861
  • 2
  • 9
  • 17
  • 1
    https://en.wikipedia.org/wiki/Rounding#Round_half_to_even This discussion here seems relevant. Also, review the IEEE standard for more information about this system. – Sycorax Jun 14 '16 at 13:37
  • This reference also gives the unhelpful example of "Thus, for example, +23.5 becomes +24, as does +24.5; while −23.5 becomes −24, as does −24.5." What about the case when we have 23.5[13 more digits]? Is there any practical need to follow this rule? – Thomas Jun 14 '16 at 13:48
  • 1
    Did you read the next paragraph? "This method treats positive and negative values symmetrically, and is therefore free of sign bias. More importantly, for reasonable distributions of y values, the average value of the rounded numbers is the same as that of the original numbers. However, this rule will introduce a towards-zero bias when y − 0.5 is even, and a towards-infinity bias for when it is odd." – Sycorax Jun 14 '16 at 13:56
  • "If we are dealing with real numbers with infinite precision, this rule is of course unnecessary." The justification for this eludes me: could you explain? I suspect you are making some implicit assumptions which, if brought into the open, might indicate how to frame a useful answer. – whuber Jun 14 '16 at 14:08
  • I am saying that if we round 23.50000000000000 to 24 and 24.500000000000000 to 25 (i.e., don't use the round to even rule) that any bias introduced is of no practical significance because the probability of getting exactly in a X.50000000000000 in a result is very small compared to getting X.5. – Thomas Jun 14 '16 at 14:10
  • What is the probability of getting exactly 0.5 in a real number? It is 0, so the round to even rule would never be invoked. – Thomas Jun 14 '16 at 14:11
  • 2
    The probability of getting exactly 0.5 floating-point number in a computer is not zero. – Aksakal Jun 14 '16 at 16:15
  • True, but I specified a real number in my statement, not a floating point number. – Thomas Jun 14 '16 at 16:17
  • It doesn't matter what's the real number in the context of your question. There's no need in rounding if you could operate real numbers. You get them in the computer, and it becomes a floating-point. – Aksakal Jun 14 '16 at 17:18
  • @Aksakal, please read the comments in order. I was responding to whuber's question about my original posting. – Thomas Jun 14 '16 at 17:29
  • 1
    Thank you for your clarification. I am now wondering what "probability" you are referring to. In some (real) applications half or more of the numbers are exact half-values! (One example: mean counts in paired data.) It therefore seems you might have some particular application or model in mind that governs the creation of numbers that will be rounded. What is it? – whuber Jun 14 '16 at 19:16
  • The data are radiochemical analytical results and their associated uncertainties. Both are reported to machine precision (16-17 digits). The uncertainty is rounded to 2 significant digits and the result is rounded to match the uncertainty.The chances of having to invoke the "round to even" rule with these data seems very small to me. – Thomas Jun 14 '16 at 19:34
  • I strongly doubt those results have accuracy comparable to that precision. At some point it would likely be helpful to report the values in a more realistic manner, using only a few significant figures. That's typically where rounding plays a role. – whuber Jun 15 '16 at 22:37
  • @whuber There's no way radiochemical analytical results are measured at 16 digits accuracy. In my distant past I dealt with that kind of data, it was nowhere near that precision. I'd love to know what kind of experiment generates this data – Aksakal Jun 16 '16 at 14:10
  • @Aksakal That's right. Indeed, *no data in the world* are that accurate. In this context, though, I think it's important to maintain the distinction between *accuracy* and *precision*. These data likely were obtained as counts (of detected decay events) divided by measured times, then renormalized according to some calibration (and then perhaps adjusted for a measured or assumed background). As a result they indeed can be recorded with 16 digits *precision* despite having (at most) a few digits *accuracy*. – whuber Jun 16 '16 at 14:18
  • @whuber, in radiochemistry it's not just the decay event counts. It's things like concentration of radioactive elements in samples, these are measured by chemical and physical methods other than decay counts. however, I agree with you in principle that the calculations will in fact produce floating point numbers with whatever number of digits that they can hold. Even in this case, say you have 16 digit number, at the time when you publish this in phys/chem journal you have to round it to significant digits, so you'll get ties left and right, like in examples in the comment to my answer below. – Aksakal Jun 16 '16 at 14:30

2 Answers2

2

There's more than one rounding rule. I doubt you'll find the reputable reference that comes to the same conclusion as you did.

There are many rounding rules. Particularly, in the floating point IEEE standard there are at least five different rules. Some programming languages such as Java support multiple rules.

Also, note that there are different ways to represent floating points even with IEEE 754 standard, e.g. binary and decimals, which may have different default rounding modes. It's not always binary representation.

Aksakal
  • 55,939
  • 5
  • 90
  • 176
  • I understand that there are many different rounding rules. Thanks for pointing out IEEE 754, which I was not familiar with. My question deals with one particular rule, the "round to even rule." It appears to be of practical significance only when one is presented with low precision results like in the example I gave. I was seeking feedback on that hypothesis. – Thomas Jun 16 '16 at 10:01
  • On practice most inputs are "low precision" in your definition. Consider typical weight and length measurements of people or animals: hardly 3 or 4 significant digits are used. Once you calculate the mean you have to round to the same 3 or 4 digits. You are bringing up highly theoretical examples which are probably encountered in quantum physics only, even there rarely. Where do you ever get 16 significant digits input? – Aksakal Jun 16 '16 at 11:53
  • I never said that all of the 16 digits were significant. Of course they are not. I am being presented with the double precision output of a code that calculates the concentration of an analyte in a sample. I am trying to round the result to an appropriate number of significant digits based on the uncertainty of the measurement. When you round a 16 digit result like this to a 2 to 4 digit result (which is more reasonable as you say) the round to even rule will almost never be invoked. All I am looking for is a conversation that leads to a yea or nay to this idea. – Thomas Jun 16 '16 at 12:25
  • Don't use this rule if you don't like it. You can switch the rule. The rule will be invoked though if you use it. E.g. if you round 4.456678943 or 4.3566589653 to 2 digits you get 4.4 for both numbers with round to even. Finally, think logically, why would people wrote ieee754 if the rule was not reasonable? – Aksakal Jun 16 '16 at 12:35
  • In R, which implements the round to even rule: signif(4.456678943,2) = 4.5 and signif(4.3566589653,2) = 4.4. – Thomas Jun 16 '16 at 18:30
  • @Thomas, you're right. that was a terrible example. the argument is still the same: there are many cases when your data comes in two digits or so of precision, and having exactly 0.5 is highly probable. that's why this rounding rule is also called banker's rule, think of dollars and cents. – Aksakal Jun 16 '16 at 19:12
  • You all have answered my question (just use the standard rounding rules). Thanks for the lively discussion! – Thomas Jun 16 '16 at 19:24
1

The core of the question was about floating point representation of numbers and rounding. Floating point numbers are hard to reason about but easy to experiment with. Given a modern computer, based on floating point arithmetics, we can use a reasonable random number generator and produce continously distributed random data, e. g. normally distributed data, and round them. We can count how many times rounding is upwards or downwards an perform a binomial test to see, whether there is a tendency towards one of them.

The following R code does that with 10^8 random numbers

set.seed(42)
# huge number of random numbers normally distributed around 100:
sampled <- rnorm(1e+08, mean=100, sd=1)
# boolean count, whether a number was rounded upwards
rounded_up <- round(sampled)>sampled
# count those booleans
tabl <- table(rounded_up)
print(tabl)
# perform binomial test on results
binom.test(x=tabl)

My result here is p = .635 If you take a few minutes time, you can test it with n = 10^9. If there is a tendency towards rounding up or down that is not significant in n = 10^9, I don't think it will ever be relevant in any process that I am going to investigate in my life.

Of course, if you round the values to say 3 digits and perform the above test, there will be a significant tendency towards rounding down:

set.seed(42)
# huge number of random numbers normally distributed around 100:
sampled <- round(rnorm(1e+08, mean=100, sd=1), digits=3)
# boolean count, whether a number was rounded upwards
rounded_up <- round(sampled)>sampled
# count those booleans
tabl <- table(rounded_up)
print(tabl)
# perform binomial test on results
binom.test(x=tabl)

will produce a p-value < 2.2e-16.

Of course, this is only simulation and not a theoretical approach, but it should still answer the question: The more digits you use, the higher an n is needed, to make a difference between standard rounding and rounding to even. Simulation is suitable to investigate, whether for a given n, the standard resolution of your software/computer (in this case R on Windows) is sufficient. If n gets larger than feasible for simulation, it's probably not possible to handle it with your statistics program anyways. So for all practical uses, simulation should be good enough.

Bernhard
  • 7,419
  • 14
  • 36
  • Your simulation appears to support my intuition that the importance of the "round to even rule" decreases as the precision of the number you are rounding increases. I would like to find a reference in the open literature that says this because it is much easier to provide a reference than a custom proof to naysayers and intervenors. – Thomas Jun 14 '16 at 15:48