{"id":747,"date":"2009-03-01T21:32:28","date_gmt":"2009-03-01T21:32:28","guid":{"rendered":"http:\/\/scientopia.org\/blogs\/goodmath\/2009\/03\/01\/rounding-and-bias\/"},"modified":"2009-03-01T21:32:28","modified_gmt":"2009-03-01T21:32:28","slug":"rounding-and-bias","status":"publish","type":"post","link":"http:\/\/www.goodmath.org\/blog\/2009\/03\/01\/rounding-and-bias\/","title":{"rendered":"Rounding and Bias"},"content":{"rendered":"<p> Another alert reader sent me a link to a YouTube video which is moderately interesting.<br \/>\nThe video itself is really a deliberate joke, but it does demonstrate a worthwile  point. It&#8217;s about rounding.<\/p>\n<p><!--more--><\/p>\n<p> The overwhelming majority of us were taught how to round decimals back in either elementary or middle school. (I don&#8217;t even recall exactly when.) The rule that most of us were taught is:<\/p>\n<ol>\n<li> If the first digit after the rounding point is 0, 1, 2, 3, or 4, then round the previous digit down;<\/li>\n<li> If the first digit after the rounding point is 5, 6, 7, 8, or 9, then round the<br \/>\nprevious digit up.<\/li>\n<\/ol>\n<p> Here&#8217;s the problem: those rules are <em>wrong<\/em>.<\/p>\n<p> The problem is that if the first digit after the rounding point is zero, you&#8217;re<br \/>\n<em>not<\/em> really rounding &#8211; that is, you&#8217;re not doing anything that <em>changes<\/em> the value of the data point. But if the first digit after the rounding point is 5,<br \/>\nthen it&#8217;s exactly halfway in-between; it&#8217;s <em>not<\/em> closer to the either the rounded up value or the rounded down value &#8211; it&#8217;s exactly between them. Always rounding 5 up will create a bias, because it&#8217;s taking the point at the middle, and shifting it as if it were closer<br \/>\ntowards the upward side.<\/p>\n<p> To demonstrate, let&#8217;s try an easy example. Suppose we&#8217;ve got the following set<br \/>\nof numbers: {0, 0.5. 1, 1.5. 2, 2.5, 3, 3.5, 4, 4.5}. Let&#8217;s compute the mean<br \/>\nof those numbers: 22.5\/10 = 2.25.<\/p>\n<p> Now, let&#8217;s round them off: {0, 1, 1, 2, 2, 3, 3, 4, 4, 5}; and then compute the mean: 25\/10 = 2.5.<\/p>\n<p> With the standard rounding rule, we&#8217;ve biased the numbers upwards enough to create a significant error!<\/p>\n<p> The correct way to round is to randomly round 5s either up or down. The standard rule, used in most scientific settings, is to pick either odd or even as the &#8220;preferred&#8221; outcome, and to always round 5s towards the preferred outcome. If we try that with our example, using<br \/>\npreferred even, the rounding is {0, 0, 1, 2, 2, 2, 3, 4, 4, 4}. Taking the mean of that, we get 22\/10 = 2.2 &#8211; which is significantly closer to the mean of the original numbers than the<br \/>\nmean rounding 5s up. The practice of rounding up adds a systematic bias to the data. It&#8217;s a very small systematic bias, but it&#8217;s a real one.<\/p>\n<p> Does it matter? Not usually. As the commentary to the video points out, over the space of a couple of years, that systematic error in rounding gas prices amounts to about a dime. For most things in our daily experience, the difference between random rounding and upward rounding for 5s is just not significant. But if you&#8217;re doing statistical analysis of<br \/>\nlarge quantities of data, or you&#8217;re doing computations that rely on a high degree of<br \/>\nprecision, then it can introduce enough error to foul your results. If you&#8217;re doing statistical analysis, it can do things like make an insignificant result appear to be statistically significant. If you&#8217;re doing high precision computations for things like<br \/>\nnavigation of a space probe through a gravitational slingshot, it can introduce enough error<br \/>\nto crash your probe.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Another alert reader sent me a link to a YouTube video which is moderately interesting. The video itself is really a deliberate joke, but it does demonstrate a worthwile point. It&#8217;s about rounding.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[74,43],"tags":[],"class_list":["post-747","post","type-post","status-publish","format-standard","hentry","category-basics","category-numbers"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p4lzZS-c3","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/posts\/747","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/comments?post=747"}],"version-history":[{"count":0,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/posts\/747\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/media?parent=747"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/categories?post=747"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/tags?post=747"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}