Rounding [Software]

posted by Helmut Homepage – Vienna, Austria, 2013-01-06 16:34 (4503 d 00:13 ago) – Posting: # 9793
Views: 12,639

Hi Yung-jin,

continuing our personal communication. THX for reminding me on the rule your professor in physical chemistry taught you. How could I forget this goodie?
  1. if the number next to the required digit ≤4, then drop it: 125.003 ⇒ 125.00
  2. if the number next to the required digit ≥6, then add 1 to the required digit: 125.008 ⇒ 125.01
  3. if the number next to the required digit =5, then
    1. if the required digit is odd, then add 1 to the required digit: 125.015 ⇒ 125.02
    2. if the required digit is even, then drop it: 125.005 ⇒ 125.00
x = 124.990–125.010, step 0.0005; y = rounded to two decimal figures. Dashed line: y = 125.005

(1) Commercial rounding:
[image]

(2) R & Maxima:
[image]

(3) Chem. rounding:
[image]


Based on the regression I would prefer (3). But the down-rounding close to 125.005 extends even further up than in R & Maxima:
            (1)    (2)    (3)
124.9950  125.00 125.00 125.00
← rule 3.1
125.0045  125.00 125.00 125.00 ← rule 1
125.0050  125.01 125.00 125.00 ← rule 3.2
125.0055  125.01 125.01 125.00 ← rule 3.2
125.0059  125.01 125.01 125.00 ← rule 3.2
125.0060  125.01 125.01 125.01 ← rule 2


Edit: It’s clear that we are loosing information in rounding. No big deal if we don’t introduce bias. Nice that R & Maxima use ‘rounding half to even’ which is overall (i.e., [–∞, 0, +∞]) less biased than ‘rounding half away from zero’. However bias exists – just a different one.
In our case we have positive numbers only. ‘Best’ algo?

BTW, is disturbed me somewhat that most replies at R-Help were like “R complies with the standard. Full stop.”

As soon as we abandon our own reason, and are content
to rely upon authority, there is no end to our troubles.
  Bertrand Russell

A central lesson of science is that to understand complex issues
(or even simple ones), we must try to free our minds of dogma and
to guarantee the freedom to publish, to contradict, and to experiment.
Arguments from authority are unacceptable.
  Carl Sagan

Anyone who conducts an argument by appealing to authority
is not using his intelligence;
he is just using his memory.
  Leonardo da Vinci


Dif-tor heh smusma 🖖🏼 Довге життя Україна! [image]
Helmut Schütz
[image]

The quality of responses received is directly proportional to the quality of the question asked. 🚮
Science Quotes

Complete thread:

UA Flag
Activity
 Admin contact
23,424 posts in 4,927 threads, 1,672 registered users;
109 visitors (0 registered, 109 guests [including 8 identified bots]).
Forum time: 17:48 CEST (Europe/Vienna)

It’s always fun to have your models validated,
but is way more fun to have them trashed.
Finding out you are completely wrong
is a great part of science.    G. Randall Gladstone

The Bioequivalence and Bioavailability Forum is hosted by
BEBAC Ing. Helmut Schütz
HTML5