You have a function that can generate a random value, it only generate True or False (1 & 0) with equal probability (50/50), now it is easy to use that function to pick out a random number out of a group of numbers if that group is one of the powers of 2, but what if it wasn't?
Use the function to make a function that picks out a random number out of 7 numbers with equal probability, how can this be done?
Question
Guest
You have a function that can generate a random value, it only generate True or False (1 & 0) with equal probability (50/50), now it is easy to use that function to pick out a random number out of a group of numbers if that group is one of the powers of 2, but what if it wasn't?
Use the function to make a function that picks out a random number out of 7 numbers with equal probability, how can this be done?
Link to comment
Share on other sites
25 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.