Saturday, September 18, 2010

Re: simple 16-bit random number generator

Bee wrote:
> simple 16-bit random number generator
>
> Do you have a favorite?
>
> I need small numbers randomized each iteration within a function. The
> following seems to work well for application.
>
>

Rndm.vim, available at
http://mysite.verizon.net/astronaut/vim/index.html#RNDM, passes Knuth's
test pretty well. From Rndm's help:


The pseudo-random number generator used herein was developed at MIT.

I used D. Knuth's ent program (http://www.fourmilab.ch/random/) and
generated
one million (1,000,000) values using a C program variant: >
rv= Rndm()/3906.25 (which divides one million into 256 equal regions)
and converted each value into bytes. The report from Knuth's ent program:

Entropy = 7.999825 bits per byte.

Optimum compression would reduce the size
of this 1000000 byte file by 0 percent.

Chi square distribution for 1000000 samples is 242.41, and randomly
would exceed this value 70.44 percent of the times.

Arithmetic mean value of data bytes is 127.5553 (127.5 = random).
Monte Carlo value for Pi is 3.135732543 (error 0.19 percent).
Serial correlation coefficient is 0.001313 (totally uncorrelated = 0.0).

These values are quite good (a true random source, for example, had a
chi square distribution value of 249.51, for example -- from Knuth's page).

Regards,
Chip Campbell

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: