miriam_e: from my drawing MoonGirl (Default)
[personal profile] miriam_e
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
This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

Profile

miriam_e: from my drawing MoonGirl (Default)
miriam_e

January 2026

S M T W T F S
    1 23
45678910
11121314151617
18192021222324
25262728293031

Style Credit

Expand Cut Tags

No cut tags
Page generated Jan. 6th, 2026 04:21 pm
Powered by Dreamwidth Studios