良い xorshift、悪い xorshift

| ← back |
| home |

視覚的に xorshift の特性の違いが分かるサンプル・プログラム
/' (c) 2021 cepstrum.co.jp '/
' FreeBASIC GUI program
' >fbc -s gui
'--------------------------------------------------------------------------
' xorshift random number generator

function uint_xorshift(a as uinteger, b as uinteger, c as uinteger) as uinteger<32>
  static r as uinteger<32> = &Hffffffff

  r=r xor (r shl a)
  r=r xor (r shr b)
  r=r xor (r shl c)
  return r
end function

'--------------------------------------------------------------------------

dim x    as uinteger
dim y    as uinteger
dim dotc as uinteger
dim a    as uinteger = 5
dim b    as uinteger = 17
dim c    as uinteger = 13
dim shft as uinteger = 1

screenres 1024, 1024

sleep 300
while inkey$<>""
wend

while inkey$=""
  x   =(uint_xorshift(a, b, c) shr shft) mod 1024
  y   =(uint_xorshift(a, b, c) shr shft) mod 1024
  dotc=(uint_xorshift(a, b, c) shr shft) mod 64
  line (x, y)-(x, y), dotc
wend



40年前の論文の指摘
| ← back | ↑top |
| home |