{"id":18187,"date":"2026-06-29T22:28:17","date_gmt":"2026-06-30T02:28:17","guid":{"rendered":"https:\/\/scruss.com\/blog\/?p=18187"},"modified":"2026-06-29T22:28:17","modified_gmt":"2026-06-30T02:28:17","slug":"home-made-random-digits","status":"publish","type":"post","link":"https:\/\/scruss.com\/blog\/2026\/06\/29\/home-made-random-digits\/","title":{"rendered":"Home-made Random Digits"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">I have always meant to do more with the idea of <a href=\"https:\/\/scruss.com\/blog\/2021\/05\/12\/applied-futility-re-creating-rands-a-million-random-digits\/\">Re-creating RAND\u2019s \u2018A Million Random Digits\u2019<\/a> but it&#8217;s a lot of effort for very little return.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This week, however, I had a chance to be my own random number generator. A routine medical investigation had me get a couple of shots of <a href=\"https:\/\/www.cardiolite.com\/\">CardioLite\u00ae<\/a>, a tracer chock-full of the radioisotope <a href=\"https:\/\/en.wikipedia.org\/wiki\/Technetium_(99mTc)_sestamibi\"><sup>99m<\/sup>Tc<\/a>. This has a half-life of just over six hours, and meant I was furiously (if harmlessly) radioactive for a couple of days.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">My trusty <a href=\"https:\/\/mightyohm.com\/blog\/products\/geiger-counter\/\">MightyOhm Geiger Counter<\/a> got some use:<\/p>\n\n\n\n<figure class=\"wp-block-video\"><video height=\"1080\" style=\"aspect-ratio: 1920 \/ 1080;\" width=\"1920\" controls src=\"https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2026\/06\/geiger.mp4\"><\/video><figcaption class=\"wp-element-caption\">At the start of this video, I&#8217;m about 4 metres and two brick walls away from the Geiger counter. After about 3 seconds of background, I walk slowly towards it and the counts pick up. After 12 seconds I put my hand over the meter tube and it goes wild.<br>(The truly ghoulish amongst you might clock the date code on the Soviet-era \u0421\u0411\u041c20 tube: <strong>03\u201387<\/strong>. Now, I wonder <a href=\"https:\/\/world-nuclear.org\/information-library\/safety-and-security\/safety-of-plants\/chernobyl-accident\">why people would be busy making these things in 1987<\/a> \u2026?)<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The first measurement I made, a little more than four hours after my second shot of CardioLite\u00ae, was over 75000 counts\/minute. As I write this, more than two days later, I&#8217;m barely registering over background level. I&#8217;m kicking myself (gently) for not thinking of rigging up this random number generator earlier, but hey: next time &#8230;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I don&#8217;t remember where I heard of this method \u2014 possibly the late John Walker&#8217;s <a href=\"https:\/\/www.fourmilab.ch\/hotbits\/hardware3.html\">HotBits<\/a> server \u2014 but random bits from radioactive decay can be found by:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"180\" src=\"https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/1782\/80\/pulse_to_bits.png\" alt=\"diagram with four rows: 1) a pulse train diagram, showing 21 randomly-spaced pulses 2) a Length \/ Duration row, showing pulse lengths of 1, 8, 6, 3, 3, 5, 9, 9, 8, 5, 1, 7, 6, 6, 2, 5, 7, 2, 6, 2 (arbitrary units) 3) a row labelled &quot;Longer?&quot;, being binary digits indicating if the current interval is longer than the previous one: 1 0 0 0 1 1 0 0 0 0 1 0 0 0 1 1 0 1 0 4) a row labelled &quot;Extract&quot;, binary digits made by comparing pairs of digits from the previous row, outputting nothing if the bits are the same, or the first bit if they are different. Only the first, sixth and ninth pairs output digits (1, 1 and 0, respectively). The last digit from the previous row has no pair and is discarded\" class=\"wp-image-18196\" srcset=\"https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/1782\/80\/pulse_to_bits.png 800w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/1782\/80\/pulse_to_bits-320x72.png 320w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/1782\/80\/pulse_to_bits-160x36.png 160w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/1782\/80\/pulse_to_bits-768x173.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><figcaption class=\"wp-element-caption\">How 21 pulses can end up representing as few as three bits<\/figcaption><\/figure>\n\n\n\n<ol class=\"wp-block-list\">\n<li>recording the time intervals between counts;<\/li>\n\n\n\n<li>If the previous interval is shorter than the most recent one, record <strong>1<\/strong>. Otherwise, record <strong>0<\/strong>;<\/li>\n\n\n\n<li>Compare pairs of bits:\n<ul class=\"wp-block-list\">\n<li>If they&#8217;re the same, discard them;<\/li>\n\n\n\n<li>If they&#8217;re different, record the first one.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">That last step is a von Neumann <a href=\"https:\/\/en.wikipedia.org\/wiki\/Randomness_extractor#Von_Neumann_extractor\">Randomness extractor<\/a>. While it consumes three quarters of the bit stream, it does clear up trivial glitches and stuck bits in the data. What it can&#8217;t help with is removing any inherent bias in the data. This won&#8217;t be a problem with background radiation, or with radioisotopes with a long half-life. Unfortunately <sup>99m<\/sup>Tc decays quite rapidly.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So here&#8217;s roughly 5:50 of background plus my own personal radiation recorded a day and a bit after getting the CardioLite\u2122 shot:<\/p>\n\n\n\n<div class=\"wp-block-file\"><a id=\"wp-block-file--media-5a4af4cf-19f4-4eda-8942-2d06cb0a2887\" href=\"https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2026\/06\/GeigerCounter-20260627125000-1s.zip\">GeigerCounter-20260627125000-1s.zip<\/a><a href=\"https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2026\/06\/GeigerCounter-20260627125000-1s.zip\" class=\"wp-block-file__button wp-element-button\" download aria-describedby=\"wp-block-file--media-5a4af4cf-19f4-4eda-8942-2d06cb0a2887\">Download<\/a><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">It&#8217;s a simple CSV file with two columns: a timestamp in microseconds, and a 1 indicating a pulse. I stripped out the 0 lines as they added nothing but bulk. The average rate over the whole file is about 2000 counts\/minute, a fraction of the initial value.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can convert these pulses into a format stream of decimal digits using this script:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n#!\/usr\/bin\/env bash\nawk -F, &#039;NR&gt;2 &amp;&amp; $2==1 {print $1-p;} $2==1 {p=$1}&#039; \\\n    GeigerCounter-20260627125000-1s.csv |\\\n    awk &#039;NR&gt;1 {print ($1&gt;p)?&quot;1&quot;:&quot;0&quot;;} {p=$1}&#039; |\\\n    paste - - |\\\n    awk &#039;(NF==2 &amp;&amp; $1 != $2) {print $1;}&#039; |\\\n    paste - - - - |\\\n    tr -d &#039;\\t&#039; |\\\n    awk &#039;length($0)==4&#039; |\\\n    while\n\tread n\n    do\n\techo &quot;$((2#$n))&quot;\n    done |\\\n    awk &#039;($1&lt;10) {print $1;}&#039; |\\\n    paste - - - - - |\\\n    awk &#039;NF==5&#039; |\\\n    tr -d &#039;\\t&#039; |\\\n    column -x\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Which produces this delightful 10-column output, just like in the book. Unfortunately, WordPress being WordPress, I have to reformat it in five columns to fit:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">24706 01995 88339 56253 13590<br>94840 27561 44882 00438 83191<br>44908 62879 31700 77035 77580<br>24259 25028 90295 80177 44425<br>77840 91877 01808 40411 78604<br>80671 11095 77770 73361 82022<br>72607 21941 22774 00291 15946<br>82318 23265 73230 92052 08205<br>87500 77977 04715 63782 23096<br>78036 62051 26806 04072 45339<br>84834 18079 09151 21061 72237<br>86391 55872 96535 39211 60718<br>69699 70154 96182 34330 37190<br>37806 79871 07121 62693 84271<br>24814 61766 25520 00808 31585<br>22257 79958 70119 78071 81958<br>90107 15800 03198 90890 32005<br>13587 49799 03401 66460 47582<br>02219 33431 77975 64865 87830<br>02630 17461 57396 47819 94379<br>28581 75002 32609 24884 38612<br>33844 63903 26378 72561 91464<br>97679 35768 39138 31780 19588<br>48088 60300 97267 84375 64982<br>88364 69709 57600 44108 08439<br>53293 85045<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Are these digits truly random? There are too few to tell. There may be some bias due to the isotope that was in me having a short half-life: the first minute&#8217;s data contains 2153 counts, while the last minute only has 2077. Whether this is due to natural variations in background radiation, I can&#8217;t tell.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have always meant to do more with the idea of Re-creating RAND\u2019s \u2018A Million Random Digits\u2019 but it&#8217;s a lot of effort for very little return. This week, however, I had a chance to be my own random number generator. A routine medical investigation had me get a couple of shots of CardioLite\u00ae, a [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_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},"jetpack_post_was_ever_published":false},"categories":[7],"tags":[3379,3377,1384,3378],"class_list":["post-18187","post","type-post","status-publish","format-standard","hentry","category-computers-suck","tag-geiger","tag-radiation","tag-random","tag-technetium"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pQNZZ-4Jl","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/18187","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=18187"}],"version-history":[{"count":6,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/18187\/revisions"}],"predecessor-version":[{"id":18200,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/18187\/revisions\/18200"}],"wp:attachment":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/media?parent=18187"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/categories?post=18187"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/tags?post=18187"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}