The distribution quirk that you quoted is only relevant when the random number range you're generating is larger than 2^32. That is 4294967296.
If you're working with numbers that big, and you need them to be randomised, then perhaps this is a reason to reconsider using mt_rand()
. However if your working with numbers smaller than this, then it is irrelevant.
The reason it happens is due to the precision of the random number generator not being good enough in those high ranges.
I've never worked with random numbers that large, so I've never needed to worry about it.
The difference between rand()
and mt_rand()
is a lot more than "just three extra characters". They are entirely different function calls, and work in completly different ways. Just the same as you don't expect print()
and print_r()
to be similar.
mt_rand()
gets it's name from the "Mersene Twister" algorithm it uses to generate the random numbers. This algorithm is known to be a quick, efficient and high quality random number generator, which is why it is available in PHP.
The older rand()
function makes use of the operating system's random number generator by making a system call. This means that it uses whatever random number generator happens to be the default on the operating system you're using. In general, the default random number generator uses a much slower and older algorithm, hence the claim that my_rand()
is quicker, but it will vary from system to system.
Therefore, for virtually all uses, mt_rand()
is a better function to use than rand()
.
You say "assuming mt_rand()
is available", but it always will be since it was introduced way back in PHP4.