Random Number Generation – PRNG


Another topic which I studied during my Bachelor, with prof Airton Deppman, was Random number generation. At that time I was quite impressed by the fact that a computer cannot generate a sequence of total random numbers, aka pseudo random generation.

So kids, do not trust those sites the promise REAL random generation cause they might be using slaves to roll the dices.

Break down MegaSena

But I faced this problem of random number generation when I first created a Program to Break “MegaSena”! My break MegaSena was a simple counting c program that generated a billion numbers “randomly” count the number of appearances and display to me the histogram and 6 numbers so I could win the MegaSena.

It was bizarre when the numbers were always 1,2,3,4,5 and 7!! or 6!! How come? So I increased the number of generated numbers for 10 billions, and after some hours the discrepancy was even lower!

So yeah, coming back to the random numbers generation, I found that Mersenne Twister was the best generator and it is the default for several languages, as C++11, MatLab, Excel and Julia.

Details of the algorithm can be found here[1] but basically it was developed in 97 by Makoto Matsumoto (松本 眞) and Takuji Nishimura(西村 拓士).

[1] https://en.wikipedia.org/wiki/Mersenne_Twister

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s