Sunday 3 February 2013

Round the twist

Weirdly, I have found this post http://alandgraf.blogspot.com.au/2012/06/rounding-in-r.html to be fascinating. Maybe I need to get out more?

That blog post deals with how to round up (or down) when you have a number that isn’t a whole number.

For example, if you have an observation or data point that is equal to 4.5 and you want to use only whole numbers in your analysis, should you round down to 4 or up to 5?

It appears that there is no hard and fast rule for doing this; some argue for down and some for up. Similarly, some software rounds down in this instance and some up.

There is actually an international standard that applies; ISO/IEC/IEEE 60559:2011 which is identical to the IEEE Standard for Floating-Point Arithmetic (IEEE 754) established in 1985. [ISO/IEC/IEEE 60559:2011 covers a zillion other aspects of numerical computing and took seven years to produce.]

In relation to the above rounding issue, ISO/IEC/IEEE 60559:2011 apparently says, in effect:

“… round numbers ending in "1, 2, 3, and 4" down, and numbers that end in "6, 7, 8, 9" up. Then, specifically regarding "5", if the preceding digit is odd, round up and if the preceding digit is even, round down.”

The advantage of this is that 50% of the numbers will be rounded up, and 50% rounded down, instead of rounding up 5/9th's of the time, and so introducing a bias.

As one statistician (and a much better one than I am) I asked about this confirmed “…the clever thing about rounding to evens is that the average is not biased when this is done.”


2 comments:

  1. Fascinating. Hey! You bought a fridge!

    ReplyDelete
  2. Very interesting! I've always been uncomfortable with a blanket round up or down; this solution is elegant and quite satisfying. Thanks for sharing.

    ReplyDelete