Dominik Christian Egert #: Yes, I agree to point 1. And see that issue as well, which I haven't taken into consideration.
But I disagree about modulo operator. Short, theoretical example: random numbers between 1 and 10, modulo by 8. You will see more of 1s and 2s. Your range must be a multiple of the modulo operator. Which is not possible with 32767 being the biggest number in the range. I need a computer to verify this.... Ha. But, MathRand() % 5 will not uniformly distribute.
That is NOT how William is using the modulus function in the example in his link. He is using modulus for the range max calculation, not against the random number generator itself.
EDIT: Correction ... Actually he is using the modulus function against the generator, but only after the filter (aka the while loop).
Dominik Christian Egert #: But I "disagree" to modulo operation,
Fernando Carreiro #: Assuming a uniformly distributed random number generator, then the modulus alternative will also be uniformly distributed.
If you had looked at the link provided, the code handles the fact that 32767 is not a multiple of 1000 and gives a uniformly distributed result using modulo.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
That is NOT how William is using the modulus function in the example in his link. He is using modulus for the range max calculation, not against the random number generator itself.
EDIT: Correction ... Actually he is using the modulus function against the generator, but only after the filter (aka the while loop).
Fernando Carreiro #: Assuming a uniformly distributed random number generator, then the modulus alternative will also be uniformly distributed.
If you had looked at the link provided, the code handles the fact that 32767 is not a multiple of 1000 and gives a uniformly distributed result using modulo.