home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / sci / math / 17296 < prev    next >
Encoding:
Internet Message Format  |  1992-12-22  |  5.1 KB

  1. Path: sparky!uunet!pipex!bnr.co.uk!uknet!acorn!armltd!dseal
  2. From: dseal@armltd.co.uk (David Seal)
  3. Newsgroups: sci.math
  4. Subject: Re: Rounding Rules
  5. Message-ID: <11005@armltd.uucp>
  6. Date: 22 Dec 92 12:43:12 GMT
  7. References: <LOTTO.92Dec21062820@math.math.berkeley.edu>
  8. Sender: dseal@armltd.uucp
  9. Distribution: sci
  10. Organization: A.R.M. Ltd, Swaffham Bulbeck, Cambs, UK
  11. Lines: 101
  12.  
  13. In article <LOTTO.92Dec21062820@math.math.berkeley.edu>
  14. lotto@math.berkeley.edu (Ben Lotto) writes:
  15.  
  16. >>>>>> On Sun, 20 Dec 1992 00:30:18 GMT, shaw@toadflax.UCDavis.EDU (Rob Shaw) said:
  17. >
  18. >Rob> What is the rationale behind the following rounding rule?
  19. >
  20. >Rob> when dealing with 5's followed by all zero's, check the
  21. >Rob> next digit to the left. If it's even, round down; odd,
  22. >Rob> round up.
  23. >
  24. >I was told way back in my undergraduate days that one should generally
  25. >"round to evens."  Someone recently explained the rationale for this
  26. >as follows.  Suppose we start with 1.49 and round in the traditional
  27. >manner twice.  First we would round to 1.5 and then to 2.  On the
  28. >other hand, if we round just once we get 1.  Rounding to evens
  29. >prevents us from getting different answers.
  30.  
  31. Sorry, this isn't true. In particular, if you actually apply the above rule
  32. to 1.5, you get 2. If instead it were "if even, round up; if odd, round
  33. down", then 1.51 would round to 1.5 and then to 1 in two roundings, but to 2
  34. in one rounding.
  35.  
  36. It is in fact impossible to produce a tie-breaking technique for the "round
  37. to nearest" rule which makes one rounding and two roundings always produce
  38. the same answer, at least if the base of your number system is even. Reason:
  39. let the base be B, and let the digit A be B/2. Consider the two numbers 1.A
  40. - 0.001 and 1.A + 0.001. Doing one single rounding to an integer, they round
  41. to 1 and 2 respectively, since they are just below and just above the "tie"
  42. case. Rounding to one place, they both round to 1.A: however we do a
  43. subsequent second rounding to an integer, they're going to come out the
  44. same. So one rounding will produce different results for the two numbers and
  45. two roundings will produce the same results for the two numbers: it is
  46. therefore impossible for the one rounding result and the two roundings
  47. result to always be the same as each other.
  48.  
  49. The real reason for this rounding rule is that it is unbiased: i.e. the
  50. expected change in the value of a number on rounding it is zero. This is not
  51. true of the ordinary "round up in the tie case" rule: e.g. rounding from 1
  52. decimal place to an integer, we have 10 equiprobable cases:
  53.  
  54.   x.0 rounds to x:   change in value =  0.0;
  55.   x.1 rounds to x:   change in value = -0.1;
  56.   x.2 rounds to x:   change in value = -0.2;
  57.   x.3 rounds to x:   change in value = -0.3;
  58.   x.4 rounds to x:   change in value = -0.4;
  59.   x.5 rounds to x+1: change in value =  0.5;
  60.   x.6 rounds to x+1: change in value =  0.4;
  61.   x.7 rounds to x+1: change in value =  0.3;
  62.   x.8 rounds to x+1: change in value =  0.2;
  63.   x.9 rounds to x+1: change in value =  0.1;
  64.   ------------------------------------------
  65.   Total change in value              =  0.5;
  66.   Average change per rounding        =  0.5/10 = 0.05.
  67.  
  68. With the even-odd rule, there are 20 equiprobable cases:
  69.  
  70.   e.0 rounds to e:   change in value =  0.0;
  71.   e.1 rounds to e:   change in value = -0.1;
  72.   e.2 rounds to e:   change in value = -0.2;
  73.   e.3 rounds to e:   change in value = -0.3;
  74.   e.4 rounds to e:   change in value = -0.4;
  75.   e.5 rounds to e:   change in value = -0.5;
  76.   e.6 rounds to e+1: change in value =  0.4;
  77.   e.7 rounds to e+1: change in value =  0.3;
  78.   e.8 rounds to e+1: change in value =  0.2;
  79.   e.9 rounds to e+1: change in value =  0.1;
  80.   o.0 rounds to o:   change in value =  0.0;
  81.   o.1 rounds to o:   change in value = -0.1;
  82.   o.2 rounds to o:   change in value = -0.2;
  83.   o.3 rounds to o:   change in value = -0.3;
  84.   o.4 rounds to o:   change in value = -0.4;
  85.   o.5 rounds to o+1  change in value =  0.5;
  86.   o.6 rounds to o+1: change in value =  0.4;
  87.   o.7 rounds to o+1: change in value =  0.3;
  88.   o.8 rounds to o+1: change in value =  0.2;
  89.   o.9 rounds to o+1: change in value =  0.1;
  90.   ------------------------------------------
  91.   Total change in value              =  0.0;
  92.   Average change per rounding        =  0.0/20 = 0.00.
  93.  
  94. This can be important e.g. when many values are added together. For an
  95. unbiased rounding rule, the total rounding error will be of the order of
  96. SQR(N) * standard deviation of change in value, where N is the number of
  97. values summed. For a biased rounding rule, this is increased by N*bias.
  98. Because of the difference in growth rate between the multipliers of SQR(N)
  99. and N, even a small bias can become the dominant source of errors for large
  100. values of N.
  101.  
  102. One other point to note: in arithmetic done by hand, the bias is +0.05 for
  103. positive values and -0.05 for negative values: this is essentially because
  104. we use a sign/magnitude representation for numbers. This *may* come out
  105. fairly unbiased if the numbers are reasonably symmetrically placed around
  106. zero. The same is *not* true of the standard two's complement representation
  107. on computers, for which the "round up in tie case" rule will have a positive
  108. bias regardless of the sign of the numbers.
  109.  
  110. David Seal
  111. dseal@armltd.co.uk
  112.  
  113. All opinions are mine only...
  114.