you can look into this thread: http://forum.mikrotik.com/t/pseudo-random-number-generator-script-mersenne-twister/51962/1