Jump to content

something better than rand or mt_rand


jonsjava

Recommended Posts

I got curious one day, so I wrote a small script that would run rand(1,1000) and mt_rand(1,000) 1,000,000 times each, and calculated the average. I had assumed that over time, the average would be somewhere around 500 (for every high, you would get a low). Well, the crazy thing is that it would hit 250 average every time, no matter the function (rand or mt_rand). I'm talking about within a decimal place of being exactly 250 for the average. That doesn't sound too random. So, the question: is there a class that is built for creating randoms that works better than the built-in random functions? If so, please point me to where I can find that.

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/116983-something-better-than-rand-or-mt_rand/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.