Блог пользователя bayram

Автор bayram, 11 лет назад, По-английски

How can I make random generator function.
random(a,b) must return number between a and b with equal probability for all numbers.
Without using any getrandom(), gettime() or similar functions of programming language.
Thanks for helping!

  • Проголосовать: нравится
  • +8
  • Проголосовать: не нравится

»
11 лет назад, # |
Rev. 2   Проголосовать: нравится +8 Проголосовать: не нравится

Just implement your own random generator. For example Linear Congruential Generator — though of course without any timing function etc you will need to seed it manually. (but it is just the same as with rand and srand functions in C)

There are many implementations so you can easily find samples. Google for "Java Random Source" or something like this if you need them.