I went through this post SHA256 output to 1-6 number range?, this post, SHA256 output to 0-99 number range? and I felt like the exact way mentioned in the first one is really helpful. I am looking for help to generalize the way for any arbitrary integer, in other words, if we want the output values in range of 0 to n where any output may get any value in the range with equal probability, how would I apply the exact way mentioned in the first post? Or is there any other way which helps?
$\begingroup$
$\endgroup$
3
-
$\begingroup$ The answer is given in SO Why do people say there is modulo bias when using a random number generator?. The keyword is the discarding. $\endgroup$– kelalakaCommented Aug 13, 2020 at 17:43
-
$\begingroup$ I've added the general case to the 0-99 question, now it should handle your question. If not, notify us. $\endgroup$– kelalakaCommented Aug 13, 2020 at 19:20
-
$\begingroup$ Thanks so much @kelalaka :) This answers my question I believe :) $\endgroup$– Subha Nawer PushpitaCommented Aug 13, 2020 at 19:23
Add a comment
|