So, how random is Rand?

Started by Mr. Analog, April 06, 2007, 08:00:01 PM

Previous topic - Next topic

Mr. Analog

There was a bit of discussion over at the Fraga boards about the random number generator they use. It really got me thinking about how Rand works and some of the things you can do to make really good seed numbers. Interestingly the number of duplicates that comes up in any given set (in say a statistical situation where there are X prize draws for Y entrants), what's even more interesting is how consistently bad a time based seed can be.

Anyway, check out the file I've attached, I had some fun running this, feel free to nit pick...

P.S. I wrote it in notepad and tested it in Firefox, so I don't know if this will work in IE (it should)

P.P.S. All the guts are in the page, if you care to monkey with them just download a copy and monkey away...

NOTE: I had to attach this file as a TXT because stupidly this forum doesn't allow RAR files and I don't have WinZip, so when you pull the file down just change the extension to .HTML and you should be good to go.
By Grabthar's Hammer

Mr. Analog

I just tested this in IE, it works fine. You'll have to allow scripting though...
By Grabthar's Hammer

Mr. Analog

BONUS!

You can use this as a dice roller! Use "Number of Entrants" as the die type (so for example, a cube would be 6) and then use the "Number of Prizes" as the number of times you want to roll it.
By Grabthar's Hammer

Mr. Analog

#3
Wow, even neater! I was looking at the probability chart for a d20 rolled over time and the curve there is very similar to the results I get with the Second * Random Byte Rand Seed.

KEEEEEEEEEEEEEEEEEEEEN!

I bet I could write a histogram generator for dice! Oooooh, that gives me an idea!
By Grabthar's Hammer

Lazybones