All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 Random Number Generator (Posted on 2004-06-08)
A particular random number generator returns positive integer n with probability 1/(2^n). (ie '1' with probability 1/2, '2' with probability 1/4, '3' with probability 1/8, etc.)

Using this random number generator, write an algorithm which chooses a random integer from 1 to 37 with equal probability.

 See The Solution Submitted by Brian Smith Rating: 2.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
 re: Implementing Thalamus's 47-bits with Brian Smith's bit-stream. | Comment 22 of 26 |
(In reply to Implementing Thalamus's 47-bits with Brian Smith's bit-stream. by Charlie)

There is a bias in the algorithm.  The number generated can be between 37^9 and 2^47.  The numbers in that range do not properly reflect an even distribution.
 Posted by Brian Smith on 2004-06-16 13:46:23

 Search: Search body:
Forums (0)