pouët.net

Go to bottom

PRNG's

category: code [glöplog]
quote Wikipedia: "If a PRNG's internal state contains n bits, its period can be no longer than 2^n results."

Internal state, what does that mean?
If I use two 8-bit registers in calculation this period 2^16 should be true, because two 8-bit registers equals 16-bits in total, even if they only perform 8-bit arithmetic...
added on the 2011-09-02 18:44:35 by rudi rudi
yes.
added on the 2011-09-02 18:51:00 by las las
as for intitial condition the best seed is the value zero.
added on the 2011-09-02 18:52:23 by rudi rudi
yea las, i was confused at first, but had to think through it.
added on the 2011-09-02 18:53:21 by rudi rudi
any ideas for testing. i was thinking of doing the Monte Carlo method, but i heard its not 100% accurate. However I want to start with something easy..
added on the 2011-09-02 18:58:43 by rudi rudi
What do you need your PRNG for? What do you want to test exactly?
added on the 2011-09-02 19:07:33 by Moerder Moerder
http://en.wikipedia.org/wiki/Diehard_tests
added on the 2011-09-02 19:17:27 by T21 T21
If you need a very fast, small prng that you can also quickly reset it seeds value while it still passes the diehard tests I can warmly recommend the xor shift randomizer.
added on the 2011-09-02 21:16:13 by Xetick Xetick
i think that is what i am using. i think its a linear congruential generator with xor bit-twiddling i am using.
added on the 2011-09-02 22:55:49 by rudi rudi
thanks for the paper anyway! everything i can read about that i understand is usefull.
added on the 2011-09-02 22:56:27 by rudi rudi
Probably not needed but you can simplify the xor shift method to an add/shuffle and reduce the code complexity by 5x
added on the 2011-09-02 23:10:07 by T21 T21
based on one's and zero's i made this 1D and 2D random walks. it has 2^16 period and is pretty small in size for generation.

i chopped up the image (its too damn big) you only see the first steps.

1D walk.
BB Image

based on the same prng i made this walk in 2D.

BB Image

2D walk, but this are based on some value from the generator using one of the variables as choosing the bits to compare. show some pretty strange output behaviour.

BB Image
added on the 2011-09-02 23:14:43 by rudi rudi
forgot to mention in the first image you see every bit in the 8-bit register. they are based on the one's or zero's. i.e. 0 goes left, 1 goes right on each step or vice versa.
added on the 2011-09-02 23:18:31 by rudi rudi
Another way to visualize the bit distribution is filling a bitplane.

BTW, does those result really differ much from doing?

x += x<<8 | x>>8;



added on the 2011-09-02 23:48:59 by T21 T21
T21: not the first and second image. the third image are a bit different when it comes to choosing what direction the particle go.
added on the 2011-09-02 23:52:16 by rudi rudi
prng for color shades:
BB Image

for same prng based on bitvalues:
BB Image
added on the 2011-09-03 00:10:23 by rudi rudi
Just to be clear, I was mentioning

x += x<<8 | x>>8;

as the actual number generator :)
added on the 2011-09-03 00:17:34 by T21 T21
T21: please geive some output of that if you cn
added on the 2011-09-03 00:34:06 by rudi rudi
BB Image

I also used this in the poison & dot ball thread
added on the 2011-09-03 00:50:56 by T21 T21
BB Image

2 example of bit plotted
added on the 2011-09-03 01:28:56 by T21 T21
Longer string (262k bit lenght)

BB Image
BB Image
added on the 2011-09-03 01:59:27 by T21 T21
oh, nice that last one
added on the 2011-09-03 04:11:28 by rudi rudi
subject matter and visual stimuli highly applauded, thanks gents
Why does it look so dithered?
Graga: Because it's very likely that the function's codomain is not Lipschitz continuous?
added on the 2011-09-03 16:58:25 by decipher decipher

login

Go to top