| Basic Commands |
Probability Puzzles |
Hypothesis Test, Count Data |
Hypothesis Test, Measured Data |
Confidence Interval, Count Data |
Confidence Interval, Measured Data |
Association / Correlation |
Regression |
Other Examples |
Bertrand
Problem
You are given three little boxes and told that box 1 has two gold coins, box 2 has one gold and one silver, and box 3 has two silver coins. You select a box and take out one coin, which turns out to be gold. What is the probability that the other coin is gold?
Resampling Procedure
If you pick out box 3 holding two silver coins, there is no chance of taking a gold coin, so you stop that trial without scoring it. In other words, the silver-silver box can be eliminated from further consideration. The problem can now be emulated by coin-flipping.
- Flip a coin. If it comes up heads, this is gold-gold. Both the first and second coins will be gold, so write "1" on a scorepad to show that the second coin was gold.
- If the coin was tails, signifying the gold-silver box, flip another coin to determine whether the first coin taken from that box was gold. If that flip comes up heads for gold, then the second coin had to be silver, so write "0" on the scorepad to show a failure, but if it comes up tails, write nothing down, because this means the first coin taken was not gold.
- Repeat (1) and (2) 1,000 times. Count all the numbers on the scorepad to determine how many times the first coin taken was gold. Add up all the "1" values, to find out how often the second coin was gold. The answer to the question is the number of "1s" divided by the size of the list on the scorepad.
Computer Implementation in Resampling Stats
MAXSIZE first 5000 second 5000
DATA (198 198) goldgold
("198" is the atomic weight of gold.) This first box contains two "198s" and is called box 7 to avoid confusion with other numbers in the GENERATE statements below.
DATA (198 108) goldsilv
Second box; "108" is the atomic weight of silver. So box 8 has one gold and one silver coin.
DATA (108 108) silvsilv
Box 9 completes the list of all three possible boxes. (As we get further, you will see that we do not actually have to draw from within the "goldgold" or "silvsilv" vectors.)
REPEAT 5000
GENERATE 1 7,9 choice
randomly select one box
IF choice=7
box 7 has two gold coins, so we know the first coin drawn must be gold, which allows us to carry on, and the second coin must also be gold.
SCORE 198 first
record our success in drawing a gold coin first
SCORE 198 second
record our inevitable success in drawing a gold coin second
END
IF choice=8
we have the goldsilv box, but which coin did we select?
SAMPLE 1 goldsilv coin
choose 1 coin from the goldsilv box
IF coin=198
gold chosen for the first coin
SCORE 198 first
SCORE 108 second
the second coin from this box must be silver if the first coin was gold
END
END
IF choice=9
do absolutely nothing, because with box 9 there is no chance of finding a gold coin
END
END
SIZE first gldfirst
How many times did we get gold initially? Note that we could have used "SIZE second" to obtain the same information
COUNT second=198 gold2nd
of these times how often was our second draw a gold?
DIVIDE gold2nd gldfirst prob
PRINT prob
Results
prob = 0.66813
Conclusion
Our empirical resampling method predicts that the chance of getting a gold coin second is 67%.
Using the logic of conditional probability, the chance should be 2/3. Thus the empirical method is in agreement with the logical method.