
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Could you explain how your reply relates to the original post?
MQL5 has its own.
Than kyou for pointing this out. In fact i did not come across these functions.
Or simply for the case [0, 1)
For a more reliable usage, use CRandom library.
https://www.mql5.com/en/code/25843
Or just use (for 0 to 1 doubles)
Hi, Amir. I would like to point to a subtle issue in your answer, that is the modulo bias.
Because, modulo by 100 does not divide the RAND_MAX range evenly, as the range of mql random number generator is from 0 to 32767 (i.e., RAND_MAX = 2^15 - 1).
So it will lead to modulo bias. As a result, the generated random numbers in the range 0 to 0.67 will have a higher chance to appear than those in the range 0.68 to 1.0
For more thorough explanation of modulo bias please see http://www.pcg-random.org/posts/bounded-rands.html
Thank you.
Hi, Amir. I would like to point to a subtle issue in your answer, that is the modulo bias.
Because, modulo by 100 does not divide the RAND_MAX range evenly, as the range of mql random number generator is from 0 to 32767 (i.e., RAND_MAX = 2^15 - 1).
So it will lead to modulo bias. As a result, the generated random numbers in the range 0 to 0.67 will have a higher chance to appear than those in the range 0.68 to 1.0
For more thorough explanation of modulo bias please see http://www.pcg-random.org/posts/bounded-rands.html
Thank you.
That's correct. If OP needs an unbiased random, better use one of the unbiased options to calculate it.