[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference rusure::math

Title:Mathematics at DEC
Moderator:RUSURE::EDP
Created:Mon Feb 03 1986
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:2083
Total number of notes:14613

794.0. "Flip You For It" by BLITZN::ROBERTS (Peace .XOR. Freedom ?) Wed Dec 02 1987 18:49

    Simple question:
    
    If all I have is a fair two-sided coin, how can I choose among n
    alternatives such that each of the alternatives has a 1-in-n chance
    of being selected?
    
    						/Dwayne
    
T.RTitleUserPersonal
Name
DateLines
794.1SMURF::DIKEWed Dec 02 1987 20:075
    Flip the coin to make a binary number (eg 1 for heads, 0 for tails)
    with enough digits to make a number lager than n.  If the generated
    number is < n, that's it.  If not, try again.
    				Jeff
    
794.2Not as general as .1, but more elegantSQM::HALLYBKhan or bust!Thu Dec 03 1987 01:154
    If the coin is, say, an MS65 $5 Gold Liberty, then you could trade
    it in for a very large table of random numbers.
    
      John :-)
794.3CLT::GILBERTBuilderThu Dec 03 1987 14:3841
794.4divide choices in half, flip, discard, repeat til doneVIDEO::OSMANtype video::user$7:[osman]eric.vt240Fri Dec 04 1987 12:0318
If I understand you correctly, you want to select just ONE out of n choices,
with equal probability, and you want to use just one coin.

First, arrange your choices from left to right, and draw a line down the
middle.

Flip the coin, and heads mean you through away the left
choices, and tails means you through away the right half.

Then repeat:  Divide the remaining choices into a left and right half,
flip, through one half away.

This method will let you choose amongst thousands of choices in less
than 20 flips, although dividing them in half each time might
be time-consuming.

/Eric

794.52^i=n ?BLITZN::ROBERTSPeace .XOR. Freedom ?Fri Dec 04 1987 15:107
    RE: .4
    
    Eric,  I'm interested in both cases.  Your method, though, would
    seem to work only when n is an integral power of two.
    
    						/Dwayne