"Coding is just like talking to a unknown girl. Once you talked to her with guts, the next time you'll never afraid",Really? Yes , try it Now !!!
Everything here is for education and learning purpose only , individual holds rights on outer posts/links etc.
Team Cracking The Code
About Me
▼
Saturday, July 16, 2011
You are provided with a bit generator which generates 1 and 0 with equal probabilities i.e. (1/2). You are required to design a function which generates numbers form 1-1000 with equal probabilities i.e. (1/1000).
10 bits required to represent number from 1 to 1000.
ReplyDeleteSo use bit generator 10 times and form a number. if its greater than 1k than ignore the number and recalculate the number.
This forms the uniform distribution, not skewed since we are neglecting the number from 1001 to 1023