1

Say I have some random data from random.org (this is for fun..)

Say I would like to convert the random data into numbers in the range 1-100.


pseudo code

top:
word = get_next_7_bits()
if word is 0 or word > 100 goto top

Whilst this is wasteful, would it give an accurate conversion from random bits to an integer range or is it naive to expect proper distribution (binary->decimal conversion)?

This is only to satisfy my curiosity, I don't need to implement anything.

jon
  • 5,986
  • 5
  • 28
  • 35

1 Answers1

1

If there is a 50-50 chance of getting a 0 or a 1, and the bits are generated independently, then yes this will give you a uniform distribution.

Oliver Charlesworth
  • 267,707
  • 33
  • 569
  • 680