What is intriguing is that RANDOM does implement its own LFSR ( on the variable specified, not a separate internal number ) so I'm surprised there's a considerable difference. Does it come down to simply initialising the five dice differently ? Does RANDOM on five separate variables all initialised as for your own LFSR and run for at least 65536 iterations perform equally well ?
That is, replace your 'fibonacci:' with -
fibonacci:
Random w0
Return
like this?
setfreq m8
w0 = $ACE1 'prime number 44257
poke 80, word w0
w0 = $6A8D 'prime number 27277
poke 82, word w0
w0 = $EA35 'prime number 59957
poke 84, word w0
w0 = $8621 'prime number 34337
poke 86, word w0
w0 = $2FF5 'prime number 12277
poke 88, word w0
main:
peek 80, word w0
gosub fibonacci
poke 80, word w0
b10=w0//6+1
peek 82, word w0
gosub fibonacci
poke 82, word w0
b11=w0//6+1
peek 84, word w0
gosub fibonacci
poke 84, word w0
b12=w0//6+1
peek 86, word w0
gosub fibonacci
poke 86, word w0
b13=w0//6+1
peek 88, word w0
gosub fibonacci
poke 88, word w0
b9=w0//6+1
sertxd (#b10,9,#b11,9,#b12,9,#b13,9,#b9,13,10)
goto main
fibonacci:
random w0
return
end
After 65.000 rolls the statistical distributions indeed look gaussian. But when I reduce the code to:
setfreq m8
main:
gosub fibonacci
b10=w0//6+1
gosub fibonacci
b11=w0//6+1
gosub fibonacci
b12=w0//6+1
gosub fibonacci
b13=w0//6+1
gosub fibonacci
b9=w0//6+1
sertxd (#b10,9,#b11,9,#b12,9,#b13,9,#b9,13,10)
goto main
fibonacci:
random w0
return
end
then the statistical distributions are not gaussian. The first code looks to have excess code: the PEEK and POKE and the initialization of W0 as RANDOM overwrites the value of W0.
I don't think that RANDOM can be affected by initializing W0. Or is RANDOM a free running LFSR which generates better statistical numbers as the interval between two calls increases? Then the PEEK and POKE could be replaced by a FOR NEXT loop to make some delay. Interesting
Herman
NL