You have a standard pack of 52 playing cards. You then shuffle them and begin to draw out cards until you have three of a kind. What is the most likely number of cards drawn when this happens?
You then shuffle another pack of 52 playing cards into the pile. What happens to the expected number of cards now? (i.e. does it double / halve / stay the same?)
DIM card(52)
DIM denCt(13)
DIM howMany(27)
DIM cum(27)
RANDOMIZE TIMER
FOR i = 1 TO 52
card(i) = i
NEXT
FOR trial = 1 TO 1000000
FOR i = 1 TO 13
denCt(i) = 0
NEXT
FOR i = 1 TO 52
s = INT(52 * RND(1) + 1)
IF i <> s THEN SWAP card(i), card(s)
NEXT
FOR i = 1 TO 27
den = INT((card(i) - 1) / 4) + 1
denCt(den) = denCt(den) + 1
IF denCt(den) > 2 THEN EXIT FOR
NEXT
howMany(i) = howMany(i) + 1
NEXT
FOR i = 1 TO 27: PRINT USING "## ######"; i; howMany(i): NEXT
FOR i = 1 TO 27
cum(i) = cum(i - 1) + howMany(i)
IF cum(i) > 500000 THEN
IF med = 0 THEN
med = i - 1 + (500000 - cum(i - 1)) / (howMany(i))
PRINT "Median is"; med
END IF
END IF
tot = tot + howMany(i) * i
NEXT
PRINT "Mean is"; tot / 1000000
produces, this time:
1 0
2 0
3 2362
4 6825
5 13503
6 22116
7 31874
8 43283
9 54959
10 66118
11 75863
12 84017
13 89483
14 90212
15 87968
16 81023
17 70907
18 58670
19 45093
20 32431
21 21024
22 12356
23 6237
24 2579
25 874
26 197
27 26
Median is 13.10638
Mean is 13.557845
|
Posted by Charlie
on 2003-11-19 17:21:29 |