{"id":16678,"date":"2021-04-25T22:06:39","date_gmt":"2021-04-26T02:06:39","guid":{"rendered":"https:\/\/scruss.com\/blog\/?p=16678"},"modified":"2025-02-11T10:55:55","modified_gmt":"2025-02-11T15:55:55","slug":"delicate-tracings-from-a-terrible-prng","status":"publish","type":"post","link":"https:\/\/scruss.com\/blog\/2021\/04\/25\/delicate-tracings-from-a-terrible-prng\/","title":{"rendered":"Delicate tracings from a terrible PRNG"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"2321\" height=\"2321\" src=\"https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2021\/04\/randu_orbit16.svg\" alt=\"\" class=\"wp-image-16661\"\/><figcaption class=\"wp-element-caption\">The two orbits of 16-bit RANDU, plotted as X-Y coordinates<\/figcaption><\/figure>\n\n\n\n<p>I\u2019d previously mentioned RANDU \u2014 IBM\u2019s standard scientific PRNG in the 1970s that was somewhat lacking, to say the least \u2014 <a href=\"https:\/\/scruss.com\/blog\/2013\/06\/07\/well-that-was-unexpected-the-raspberry-pis-hardware-random-number-generator\/\">some time ago<\/a>, but I found a new wrinkle.<\/p>\n\n\n\n<p>For their <a href=\"https:\/\/en.wikipedia.org\/wiki\/IBM_1130\">1130<\/a> small computer system, IBM published the <a href=\"http:\/\/media.ibm1130.org\/1130-106-ocr.pdf\">Scientific Subroutine Package<\/a> [PDF], which included a cut-down version of RANDU for this 16-bit machine. The code, on page 64 of the manual, doesn&#8217;t inspire confidence:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nc     RANDU - from IBM Scientific Subroutine \nc     Package Programmer&#039;s Manual\nc     1130-CM-02X - 5th ed, June 1970\nc     http:\/\/media.ibm1130.org\/1130-106-ocr.pdf\n\n      SUBROUTINE RANDU(IX, IY, YFL)\n      IY = IX * 899\n      IF (IY) 5, 6, 6\n 5    IY = IY + 32767 + 1\n 6    YFL = IY\n      YFL = YFL \/ 32727.\n      RETURN\n      END\n<\/pre><\/div>\n\n\n<p>(If you&#8217;re not hip to ye olde Fortran lingo, that bizarre-looking IF statement means <em>IF (IY &lt; 0) GO TO 5; IF (IY == 0) GO TO 6; IF (IY &gt; 0) GO TO 6<\/em>)<\/p>\n\n\n\n<p>It accepts an odd number &lt; 32768 as a seed, and always outputs an odd number. Yes, it basically multiplies by 899, and changes the sign if it rolls over. <em>Umm<\/em> \u2026<\/p>\n\n\n\n<p>There are two possible orbits for this PRNG, each 8192 entries long:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Starting seed 1 (899, 21769, 7835, \u2026, 18745, 9003, 1, 899)<\/li>\n\n\n\n<li>Starting seed 5 (4495, 10541, 6407, \u2026, 28189, 12247, 5, 4495).<\/li>\n<\/ol>\n\n\n\n<p>The plot above is the first series as X and the second as Y. I used INTEGER*2 types to simulate the 1130&#8217;s narrow integers.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I\u2019d previously mentioned RANDU \u2014 IBM\u2019s standard scientific PRNG in the 1970s that was somewhat lacking, to say the least \u2014 some time ago, but I found a new wrinkle. For their 1130 small computer system, IBM published the Scientific Subroutine Package [PDF], which included a cut-down version of RANDU for this 16-bit machine. The [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[7],"tags":[2789,1384,3263],"class_list":["post-16678","post","type-post","status-publish","format-standard","hentry","category-computers-suck","tag-plotter","tag-random","tag-randu"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pQNZZ-4l0","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/16678","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/comments?post=16678"}],"version-history":[{"count":5,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/16678\/revisions"}],"predecessor-version":[{"id":17750,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/16678\/revisions\/17750"}],"wp:attachment":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/media?parent=16678"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/categories?post=16678"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/tags?post=16678"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}