Re: Rounding errors
From: Richard (riplin_at_Azonic.co.nz)
Date: 08/24/04
- Next message: Richard: "Re: Fujitsu COBOL and NOTRUNC option"
- Previous message: Yiorgo Terzis: "Re: Microfocus Printing in Columns"
- In reply to: Robert Wagner: "Rounding errors"
- Next in thread: Robert Wagner: "Re: Rounding errors"
- Reply: Robert Wagner: "Re: Rounding errors"
- Reply: Richard: "Rounding forward"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 24 Aug 2004 12:36:02 -0700
Robert Wagner <robert@wagner.net.yourmammaharvests> wrote
> Intuition tells us half the numbers will round up and half will
> round down. Given a very large sample, the average will remain .500 ..
> we think.
It may be what you had thought, but why do you assume that everyone
else thought that ?
> It turns out, we and Cobol are wrong. We're introducing a bias.
It turns out that _you_ are wrong, not "we".
> Suppose we have a million random numbers formatted v999, adding up to
> 500,000. Let's divide them into three groups: one containing rightmost
> digit of zero, a second containing 1-4 and a third containing 5-9.
> Let's round each group the Cobol way and sum the rounded numbers.
>
> Digit Population Sum
> 0 100,000 50,000
> 1-4 400,000 200,000 - 1,000 (-.0025 * 400,000)
> 5-9 500,000 250,000 + 1,500 (+.0003 * 500,000)
> Total 500,500
Your methodology is flawed. In fact you have made a gross statistical
error.
The fault is that you have claimed they were 'random' when you have
contrived to truncate after the third digit. If they had not been
truncated and you had left the remaining additional digits in, say, a
v99999999 and then added them up you would have got very close to the
total of 500,500.
So the flaw is not that the rounding at the third digit increased the
rounded total, but your truncation of the 4th and later digits
decreased the original total.
> Here's another way of looking at what we did. We discarded the
> rightmost digit, producing numbers that look like v99. Then we left
> half of them unchanged and added .01 to the other half. By doing so,
> we increased the total by (.01 * 500,000) = 500.
No. The rounded answer is correct. You had trucated the original
random numbers by an average of .0005 in making them v999. 1,000,000
x .0005 is the 500 that rounding correctly restored.
> The most common solution is Bankers' Rounding, the rules of which say
> right-digit 1-4 rounds down, 6-9 rounds up, 5 rounds down when the
> second digit is even and up when it's odd. The previous model, with
> addition of a group for 5s, produces this outcome:
I have done systems that carry the rounding forward. That is when the
first number is rounded the difference is added to the next number
before that is rounded (or truncated, as preferred). This ensures
that the total is always correct rather than being randomly incorrect
by a small amount.
> I find it ironic that we criticize floating-point for being too
> inaccurate for business use due to rounding errors
No. Wrong. "We" don't criticise floating-point for 'rounding errors'
at all. We criticise floating-point for not being able to represent
numbers exactly.
a = 0.50 * 2.0
if ( a == 1.0 ) <- is not true
> while at the same
> time we've been making much larger rounding errors for 40+ years.
> Single-precision floating-point errors are on the order of 10 parts
> per million; double-precision is orders of magnitude better. Our error
> is 500 parts per million.
Why do you insist on using plural for your singular errors ?
- Next message: Richard: "Re: Fujitsu COBOL and NOTRUNC option"
- Previous message: Yiorgo Terzis: "Re: Microfocus Printing in Columns"
- In reply to: Robert Wagner: "Rounding errors"
- Next in thread: Robert Wagner: "Re: Rounding errors"
- Reply: Robert Wagner: "Re: Rounding errors"
- Reply: Richard: "Rounding forward"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|