I'm not able to figure out why total is not equal to 6000, but sometimes higher, and sometimes lower ? Am I off by one somewhere? (PB 5.31, Windows 8.1, 32-bit)
Note: I created balancedCryptRandom() so that a power of 2 minus 1 is always passed to CryptRandom(), as per the help file.
Code: Select all
OpenCryptRandom()
procedure balancedCryptRandom(x)
j=1
repeat : j*2 : until j>x
Repeat
dice = CryptRandom(j-1) + 1
Until dice <= x
ProcedureReturn dice
EndProcedure
dim results(6)
for i=1 to 6000
results(balancedCryptRandom(6)) + 1
; jj + 1
next
for i=1 to 6
debug "Value " + i + " occurred: " + results(i) + " times."
total + results(i)
next
debug total
; debug jj

