aark@ihuxe.UUCP (08/23/83)
The following problem engendered a lot of argument as to whether the answer was 1/2 or 2/3: | You are in a room with three cabinets, each of which has | two drawers. One cabinet has a gold coin in each drawer. Another | has a silver coin in each drawer. The third has a gold coin in one | drawer and a silver coin in the other. | | You pick a cabinet at random and open a random drawer. It contains | a gold coin. What is the probability that the other drawer of that | same cabinet contains a gold coin? I and others were skeptical that the correct answer was 2/3. Someone suggested running a simulation program. Here is the program I wrote: | #include <stdio.h> | | #define GOLDCOIN 0 | #define SILVERCOIN 1 | #define NUMCABINETS 3 | #define NUMDRAWERS 2 | | int cabinet [NUMCABINETS] [NUMDRAWERS] = | { | { GOLDCOIN, GOLDCOIN }, | { GOLDCOIN, SILVERCOIN }, | { SILVERCOIN, SILVERCOIN } | }; | | main ( argc, argv ) | int argc; | char * * argv; | { | void srand48(); | long r, reps, atol(), lrand48(), time(); | long ns1, ng1, ng1g2, ng1s2; | int j, k; | | if ( argc != 2 || ( reps = atol ( argv[1] )) <= 0L ) | { | printf ( "Usage: coins #-of-repetitions\n" ); | exit (1); | } | srand48 ( time ((long *)0) ); | ns1 = ng1 = ng1g2 = ng1s2 = 0L; | for ( r = 0L; r < reps; r ++ ) | { | j = (int) ( lrand48() % NUMCABINETS ); | k = (int) ( lrand48() % NUMDRAWERS ); | if ( cabinet[j][k] == GOLDCOIN ) | { | ng1 ++; | if ( cabinet[j][k==0?1:0] == GOLDCOIN ) | ng1g2 ++; | else | ng1s2 ++; | } | else | ns1 ++; | } | printf ( "Three-Cabinet Problem Experiment\n\n" ); | printf ( "DATA\n\n" ); | printf ( "A. Total trials: %ld\n", reps ); | printf ( "B. First drawer silver: %ld\n", ns1 ); | printf ( "C. First drawer gold: %ld\n", ng1 ); | printf ( "D. First drawer gold, second drawer silver: %ld\n", ng1s2 ); | printf ( "E. First drawer gold, second drawer gold: %ld\n\n", ng1g2 ); | printf ( "RESULTS\n\n" ); | printf ( "Probability that first drawer, chosen randomly, contains a gold coin:\n" ); | printf ( "\tC/A = %.10f\n\n", ((double) ng1 / (double) reps ) ); | printf ( "Probability that second drawer in same cabinet contains a gold coin,\n" ); | printf ( "once the first drawer is known to contain a gold coin:\n" ); | printf ( "\tE/C = %.10f\n", ((double) ng1g2 / (double) ng1 ) ); | } This will give us an approximation to the correct answer, agreed? Running it for 1,000,000 trials by typing "coins 1000000" produced the following results: | Three-Cabinet Problem Experiment | | DATA | | A. Total trials: 1000000 | B. First drawer silver: 499685 | C. First drawer gold: 500315 | D. First drawer gold, second drawer silver: 166739 | E. First drawer gold, second drawer gold: 333576 | | RESULTS | | Probability that first drawer, chosen randomly, contains a gold coin: | C/A = 0.5003150000 | | Probability that second drawer in same cabinet contains a gold coin, | once the first drawer is known to contain a gold coin: | E/C = 0.6667319589 These experimental results support the theoretical conclusion that the problem's answer is 2/3, to four significant digits (0.6667). R.I.P. -- Alan R. Kaminsky Bell Laboratories, Naperville, IL ...ihnp4!ihuxe!aark
seth@hp-cvd.UUCP (08/27/83)
#R:ihuxe:-30600:hp-cvd:7600010:000:252 hp-cvd!seth Aug 25 09:27:00 1983 Are you sure that you are not ignoring the initial conditions? That is, you are given that you open a drawer and it contains a gold coin, and then are asked what's the probability of the second drawer containing a gold coin. --Seth Alford hp-cvd!seth