'Who has the same birthday?
'Image from edscave.com
CONST False
= 0, True
= NOT False
, Qty%
= 3000
'Populate an array with equal probability of 1 to 365, with 366 having a quarter of this probability
'This accounts for February 29th
Days%(N% * 365 + M%) = M% + 1
Days%(1460) = 366
'Image of probability from theory
'LINE (80, 338)-(90, 338) Construction lines to find origin and top-right of graph
'LINE (85, 333)-(85, 343) to get scale of plotting graph
'LINE (567, 51)-(567, 61)
'LINE (562, 56)-(572, 56)
LINE (0, 0)-(599, 399), _RGBA32(120, 120, 120, 150), BF
PrevY% = 338
REDIM Birthdays%
(NoFolks%
- 1) NoSame% = 0
'Randomise birthdays of participants
FOR M%
= 0 TO NoFolks%
- 1 Birthdays%
(M%
) = Days%
(INT(RND * 1461)) 'Now find any pairs whose birthdays are the same
TwoSame%% = False
I% = 1
J% = 2
IF Birthdays%
(I%
- 1) = Birthdays%
(J%
- 1) THEN TwoSame%% = True
J% = J% + 1
I% = I% + 1
J% = I% + 1
IF TwoSame%%
THEN NoSame%
= NoSame%
+ 1 'Print probabilities onto theoretical graph
LINE (PrevX%
, PrevY%
)-(85 + CINT(4.82 * NoFolks%
), CINT(338 - 2.82 * NoSame%
* 100 / Qty%
)) ', _RGB32(255, 255, 0) PrevX%
= 85 + CINT(4.82 * NoFolks%
) PrevY%
= CINT(338 - 2.82 * NoSame%
* 100 / Qty%
)