32 members of our social group use the weekly results of our national lotto draw for our competition. Each person selects a set of 3 numbers from just one of the coloured grids of the map shown below, such that they are all in a row (e.g. 31, 32 and 33) or in a column (e.g. 23, 29 and 35) or diagonally (e.g. 06, 11 and 16):










01 
02 
03 

04 
05 
06 


07 
08 
09 

10 
11 
12 


13 
14 
15 

16 
17 
18 











19 
20 
21 

22 
23 
24 


25 
26 
27 

28 
29 
30 


31 
32 
33 

34 
35 
36 










Our national lotto draws, each week, 5 numbers from the set of 36 numbers, and we permanently mark these 5 numbers in our map. The winner in our competition will be the person who firstly has his 3 numbers marked.
What is the probability that our competition:
a) ends in the first week?
b) ends in the second week?
c) ends in the third week?
And the most important:
d) What is the expected number of weeks for us to have a winner?
After 1,000,000 trials of a simulation, the following are the number of times that it took the given number of weeks:
weeks: 1 2 3 4 5 6 7 8 9 more
occurrences: 44471 324823 402107 182870 39741 5341 597 50 0 0
percent: 4.4471 32.4823 40.2107 18.2870 3.9741 0.5341 0.0597 0.0050 0 0
The mean number of weeks (serving as an estimate of the expectation) is 2.867248.
FOR trial = 1 TO 1000000
REDIM bd(4, 3, 3)
hit = 0
FOR drwng = 1 TO 9
REDIM used(36)
FOR chc = 1 TO 5
DO
r = INT(RND(1) * 36)
LOOP WHILE used(r)
used(r) = 1
quad = INT(r / 9) + 1: r = r MOD 9
row = INT(r / 3) + 1
col = (r MOD 3) + 1
bd(quad, row, col) = 1
NEXT
FOR quad = 1 TO 4
FOR row = 1 TO 3
f = 1
FOR col = 1 TO 3
IF bd(quad, row, col) = 0 THEN f = 0: EXIT FOR
NEXT
IF f THEN hit = 1: EXIT FOR
NEXT
IF hit THEN EXIT FOR
FOR col = 1 TO 3
f = 1
FOR row = 1 TO 3
IF bd(quad, row, col) = 0 THEN f = 0: EXIT FOR
NEXT
IF f THEN hit = 1: EXIT FOR
NEXT
IF hit THEN EXIT FOR
f = 1
FOR row = 1 TO 3
col = row
IF bd(quad, row, col) = 0 THEN f = 0: EXIT FOR
NEXT
IF f THEN hit = 1: EXIT FOR
f = 1
FOR row = 1 TO 3
col = 4  row
IF bd(quad, row, col) = 0 THEN f = 0: EXIT FOR
NEXT
IF f THEN hit = 1: EXIT FOR
NEXT
IF hit THEN EXIT FOR
NEXT
stat(drwng) = stat(drwng) + 1
IF trial MOD 10000 = 0 THEN
FOR i = 1 TO 10: PRINT stat(i); : NEXT: PRINT trial
END IF
NEXT trial
PRINT
expect = 0
FOR i = 1 TO 10
expect = i * stat(i) / (trial  1) + expect
NEXT
PRINT expect

Posted by Charlie
on 20090612 15:57:05 