Oct. 17th, 2025

miriam_e: from my drawing MoonGirl (Default)
Found a really interesting pseudo-random number generator that simulates the roll of six-sided dice. It was on the Wikipedia page for the TI-57 Texas Instruments programmable calculator. (It was my first computer. I still use an emulator of the TI-57 on my Android smartphone from time to time.)
π (pi)
+
RCL 0
=
yˣ
8
-
Int 
=
STO 0
x (multiply)
6
+
1
=
Int 
R/S (stop and start)
RST (reset back to step 00)
I rewrote it as an awk one-liner:
awk 'BEGIN{
   pi = 3.14159265358979323846264338327950 ;
   for (n=0;n<20;n++){
      a=pi+b ; a=a**8 ; b= a-int(a) ; a=b*6+1 ;
      printf int(a) "  "
   }
   print ""
}'
Its output looked a bit biased to me so I wrote a quick check to see how frequently the different numbers come up in 2,000 rolls:
awk 'BEGIN{
   pi = 3.14159265358979323846264338327950 ;
   for (n=0;n<2000;n++){
      a=pi+b ; a=a**8 ; b= a-int(a) ; a=b*6+1 ; c[int(a)]++
   }
   print c[1], c[2], c[3], c[4], c[5], c[6]
}'
Surpisingly even spread:
354 316 346 327 331 326

Profile

miriam_e: from my drawing MoonGirl (Default)
miriam_e

December 2025

S M T W T F S
 123456
7 8 910 111213
1415 1617181920
21222324252627
28293031   

Style Credit

Expand Cut Tags

No cut tags
Page generated Dec. 24th, 2025 11:08 am
Powered by Dreamwidth Studios