1

Here is a interview question: use uniformly distribution $\{1,2,3,4,5\}$ to generate $\{1,2,3,4,5,6,7\}.$

My solution is using quinary (5) number with 2 digitals, i.e. we can generate uniformly distribution $00$ to $44$ = $\{0, 1, 2,\cdots, 24\},$ then discard last 4 numbers and use $\{0, 1, 2, \cdots, 20\}$ to generate $\{1,2,3,4,5,6,7\}$ by mod 7.

Is there any standard way to solve such problem?

user6703592
  • 745
  • 3
  • 8
  • 1
    You may wish to review the analyses at https://stats.stackexchange.com/questions/406723/draw-integers-independently-uniformly-at-random-from-1-to-n-using-fair-d6 or https://stats.stackexchange.com/questions/354678/brain-teaser-how-to-generate-7-integers-with-equal-probability-using-a-biased-c/ which are largely similar – Sycorax Nov 17 '20 at 16:50

0 Answers0