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?
Asked
Active
Viewed 57 times
1
-
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. – kelalaka Aug 13 '20 at 17:43
-
I've added the general case to the 0-99 question, now it should handle your question. If not, notify us. – kelalaka Aug 13 '20 at 19:20
-
Thanks so much @kelalaka :) This answers my question I believe :) – Subha Nawer Pushpita Aug 13 '20 at 19:23