2

At school we were taught that (+/-)0.5 goes to nearest "higher" number or "round half away from zero".
That is 0.5 -> 1 and -0.5 -> -1.

away from zero

While that looks nice and all (five goes to ten regardless of a sign), the more you think about it, the less it makes sense. Then when you actually start implementing some calculations with rounding in a programming language, you soon discover that every library does it differently.

The various rounding methods
various rounding methods


My question is/are:

What is the most reasonable method for rounding with perfectly random distribution and without any preference?
This means I don't get more positive/negative, odd/even numbers. And I don't need to adjust rounding for a special use case such as finance, engineering, etc.

How do mathematicians round equidistant numbers in practice?

Is there some well accepted international standard for this?


images:
https://en.wikipedia.org/wiki/Rounding
https://www.mathsisfun.com/numbers/rounding-methods.html

Qwerty
  • 121
  • here is a guide to some of the standard rounding conventions. – lulu Jan 28 '22 at 21:01
  • @lulu Oh yeah, I used the image from there. I forgot to include sources. Anyway that site more describes all the various rounding methods, rather than the convention or best practice. Hence why I am here. – Qwerty Jan 28 '22 at 21:09
  • 1
    That's because there isn't a universally accepted method. – lulu Jan 28 '22 at 21:11
  • @lulu haha, dang! So, at least, what would a real mathematician most likely use? For any reason: personal / statistical / ease of use / comprehension / reasonability... – Qwerty Jan 28 '22 at 21:13
  • Nor is there a clear notion of what "optimal" would mean. In practice, I have tended to use dithering or to stochastically round, whenever the bias might be troubling. – lulu Jan 28 '22 at 21:18

1 Answers1

1

Let $\mathbb Z=\{\ldots-2,-1,0,1,2,\ldots\}$ be the set of integers.

Let $\frac12\mathbb Z = \{\ldots-2,-\frac32,-1,-\frac12,0,\frac12,1,\frac32,2,\ldots\}$ be the set of integers and half-integers.

In this domain, a rounding function is a function $f:\frac12\mathbb Z\to\mathbb Z$ such that $f(n)=n$ when $n$ is an integer, and $f(x)=x\pm\frac12$ otherwise.

You are asking for a rounding function $f$ that has the following additional properties:

  1. (No preference for particular numbers) For all $n$, the number of $x\in \frac12\mathbb Z$ such that $f(x)=n$ is a constant that does not depend on $n$. (This constant must be $2$.)
  2. (No preference for positive/negative) If $f(x)=0$ then $f(-x)=0$.

These properties are incompatible with each other!

  • Property (1) requires that there are exactly two values in $\frac12\mathbb Z$ that round to $0$: either $\{-\frac12, 0\}$ or $\{0,\frac12\}$.
  • But property (2) requires that an odd number of values in $\frac12\mathbb Z$ round to $0$: either $\{0\}$ or $\{-\frac12,0,\frac12\}$.

We conclude that an unbiased rounding function meeting the above criteria does not exist. As a result, the appropriate rounding function to use for a given application depends on the particular demands of the application.

Chris Culter
  • 26,806
  • I don't feel like 2) is right. What if we step up all the numbers in the halfs+integers set by 10, perform rounding, and then step down the result by 10 - shouldn't the result be the same? Hence use the same rounding rules across the whole set, regardless of sign or value. – Qwerty Jan 28 '22 at 21:42
  • Well, what did you mean by "I don't get more positive/negative", exactly? – Chris Culter Jan 28 '22 at 21:47
  • That should have meant that I will get roughly same amount of positive and negative numbers on the input, which I mentioned in case where some methods could yield smaller numbers on average as a result. But I don't really know what I am talking about, haha. – Qwerty Jan 28 '22 at 22:08
  • Sure, so starting from an input distribution of ${-\frac12,\frac12}$, which is balanced between one positive and one negative number, the output should also have the same number of positive and negative numbers. Equivalently, if one output is $0$ then the other one also has to be $0$. – Chris Culter Jan 28 '22 at 22:38
  • I see, so this is why we have rounding towards or away from zero or half to even or odd. Therefore, that was completely wrong "requirement" from me especially given my later counter-argument. Thank you for teaching me a lesson. Why is {0} and {-1/2, 0, 1/2} not mentioned on wikipedia? That's such a great example. – Qwerty Jan 28 '22 at 22:57
  • 1
    Thanks for the kind words! I've done some math writing on Wikipedia, although not that article. Generally, Wikipedia isn't optimized for explaining why things are the way they are. Even in mathematics, where objective truth is possible, the project has an aversion against making original arguments. So if I wanted to add the {0} and {-1/2, 0, 1/2} example to a Wikipedia article, I would first try to find a reputable textbook or research article that uses the example, so that I could cite that as my source. This friction makes it less likely that someone will go to the effort. – Chris Culter Jan 29 '22 at 00:08