LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (June 2001, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Thu, 14 Jun 2001 15:49:58 -0700
Reply-To:   Dale McLerran <dmclerra@MY-DEJA.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Dale McLerran <dmclerra@MY-DEJA.COM>
Subject:   Re: Round up Not down
Comments:   To: john.w@mediscience.co.uk
Content-Type:   text/plain

John,

Let me try to explain the rounding rule that I was taught. Suppose that X falls within the range (XL, XU). If X-XL<XU-X, then round off to XL. If X-XL>XU-X, then round off to XU. Now, what about the situation where X-XL=XU-X? If we always round X to XU for all intervals (XLi,XUi), then Y=round(X, <round-off-unit>) has the property that E(Y)>E(X).

So, what is the rule that I suggest should be employed when X-XL=XU-X? First, let's standardize the problem so that we are rounding off to the nearest integer value. This round-off problem is obtained if we divide X by the round-off-unit. Note that now, XL and XU are integer valued, and one of XL or XU will be even and the other odd. Choose whichever of XL, XU is even as the value to round off to.

Examples:

round(10.5,1) = 10 XL=10, XU=11

round(11.5,1) = 12 XL=11, XU=12

round(7+1/128, 1/64) XL=7+0/128, XU=7+2/128 = round(64*7 + 1/2, 1)/64 XL=7+0/64, XU=7+1/64 = ((64*7) + round( 1/2, 1) )/64 XL=0, XU=1 = (64*7 + 0)/64 = 7

round(7+3/128, 1/64) XL=7+2/128, XU=7+4/128 = round(64*7 + 3/2, 1)/64 XL=7+1/64, XU=7+2/64 = ((64*7) + round( 3/2, 1) )/64 XL=1, XU=2 = (64*7 + 2)/64 = 7.03125

Is this clear as mud?

Dale

>Date: Thu, 14 Jun 2001 22:05:28 +0100 >To: Dale McLerran <dmclerra@my-deja.com>, SAS-L@LISTSERV.UGA.EDU >From: John Whittington <John.W@mediscience.co.uk> >SUBJECT >At 11:24 14/06/01 -0700, Dale McLerran wrote: > >>You and I apparently have different rounding rules. Consider x=i+.5 >>for i an integer value. Also, let y=round(x). I was always taught >>that we should round to the nearest even value so that in expectation, >>the mean of y is equal to the mean of x (assuming that the probability >>of an odd value for i is 1/2). > >Hmmmm - yes, we do have different rounding rules - and the one I (and I >think most other people, as well as, it seems, SAS) were taught is far less >sophisticated than yours. In essence I was never taught anything more >sophisticated that the 'elementary school' rule (for 'conventional >rounding' to whole numbers of significant digits) that one 'rounded up' if >the the first 'insignificant' digit was EQUAL TO OR greater than 5, >otherwise one 'rounded down'. > >I'm not sure that I completely understand the rule you have described. I >can't really believe that you are suggesting that, say, 0.49 'rounded to >one decimal place' should be 0.4 (clearly the nearest even most significant >digit); I think I must be undertsanding you. > >>I note, though, that SAS does not implement my rule, but rather >>implements your rule as demonstrated in the following program. > >Indeed - and if one really wants to see where the transition (between >rounding up and rounding down) occurs, it can be demonstrated with a >program such as: > >data test; > do i=0.499999 to 0.5000003 by 0.0000001; > x = round(i); > put i= x= ; > end; >run; > >>Personally, I do not like this behavior. Always rounding up for the >>value that is halfway through the interval will result in a mean >>value that is always larger than the true mean in any set of data. >>Arrrrggggghhhhh!!!! > >Well, not ANY set of data - only sets that contain values exactly halfway >through rounding intervals - but, yes, in such sets of data I agree with >what you are saying, and also agree that the ideal method of rounding would >be such that E[round(x)] = E[x]. I'm surprised that neither I nor anyone >who has ever taught me has even raised this issue before, let alone >proposed a better method of rounding! That better method (and I'm sure >that 'your' method is an example of that) is one which results in equal >probabilities of a 'halfway value' being rounded up or down. Random would >be one (probably the best) way, but your method (when I understand it >properly) presumably does it in a more structured, and therefore more >readily applied, (albeit data-dependent) fashion. > >Perhaps you could explain 'your' rule in a little more detail, because I >clearly have not understood it. > >Kind Regards > > >John > >---------------------------------------------------------------- >Dr John Whittington, Voice: +44 (0) 1296 730225 >Mediscience Services Fax: +44 (0) 1296 738893 >Twyford Manor, Twyford, E-mail: John.W@mediscience.co.uk >Buckingham MK18 4EL, UK mediscience@compuserve.com >----------------------------------------------------------------

--------------------------------------- Dale McLerran Fred Hutchinson Cancer Research Center mailto: dmclerra@fhcrc.org Ph: (206) 667-2926 Fax: (206) 667-5977 ---------------------------------------

------------------------------------------------------------ --== Sent via Deja.com ==-- http://www.deja.com/


Back to: Top of message | Previous page | Main SAS-L page