Answer the question
In order to leave comments, you need to log in
What number is generated by php function mt_rand?
Hi guys!)
I wondered what the php mt_rand() function ultimately returns - "a random integer" or is it still a "pseudo-random integer"?
The php documentation says the following:
"mt_rand - Generates a random value by a method using a prime number generator based on the Mersenne Twist"
further down the text, there is this line:
"Random integer value between min (or 0) and max (or mt_getrandmax(), inclusive), or false if max is less than min."
Since the mt_rand function uses the Mersenne twister method, you can look at the description of this method on Wikipedia, and we will see the following, in the very first line:
"Mersenne twister,
Also, if we turn to the monograph by Averin G.V. "SYSTEMODYNAMICS", we will see on lines 88-89, a description of the PRNG and on page 89 there is such a sentence:
"The Mersenne vortex algorithm, based on the properties of Mersenne prime numbers, has also become widespread. Such algorithms make it easy to reproduce pseudo-random numbers with a uniform distribution , however, sequences of such numbers do not always satisfy all tests for randomness"
Do I understand correctly that the mt_rand () function, which uses the Mersenne Twirl based prime number generator method, inherently returns not a "random number", but a "pseudo-random number" ?
Please help me understand this nuance.
Answer the question
In order to leave comments, you need to log in
All software number generators do not generate true random numbers.
There are real RNGs, but usually this is such a thing that is hooked up to a computer and is quite rare live, google about them if you are interested.
There is a workaround - let the user move the mouse and randomly press the buttons to accumulate entropy and make really random numbers on this basis, but in PHP, as you understand, this is not used.
Pure coincidence is almost a myth. It's like something that is not factorizable, not decomposable into algorithms, does not depend on the weather or the position of the stars or space noise, etc., and at the same time correctly outputs values.
Therefore, everywhere there is either a mathematical algorithm that satisfies some pseudo-random criteria, or some kind of physical device based on the randomness of the environment.
But in general, even in extreme cases, the latter is more than enough.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question