Here's my take on the original problem (which I originally ignored, for various reasons):
simulate=: i. {.&.:>:@:I.@:~:"(1) 4 i.~"1@:<.@:%~ 1461 ?@:$~ 10 500 , ] mean=: +/ % # task=: [: (,mean) [: mean"1 simulate task 366 23.376 23.48 23.676 23.434 23.624 23.416 24.662 23.516 23.876 23.86 23.692 Here's a guide to the numbers: 10 500: the number of required trials 1461: 1 + 4*365 -- the number of days in four years 4: the number of years in a leap year cycle 1: the rank of a single trial So, yes, I did bother with the minor detail of including leap years. I also assumed that the size of the population born in 1900 was ignorable. The result has 11 means -- the first 10 are means for 500 trials, the last mean is the mean of the previous 10 means. The task did not specify how many people were present. However, since there are only 366 possible distinct birthdays, I can ignore groups larger than 366 people. I elected to represent "no matching birthday" with a trial result of _1, which would influence the means if fewer than 366 people were used in a trial. (Nothing was specified about this case, so I am mostly ignoring it. You could simplify my simulation further by eliminating the treatment which gives _1 for the no matching birthday cases: simulate=: i. i.&0@:="(1) 4 i.~"1@:<.@:%~ 1461 ?@:$~ 10 500 , ] You could further simplify it by ignoring leap years. This biases the results with a systematic error on the order of 1/1461 or about 0.07%. simulate=: i. i.&0@:="(1) 365 i.~"1@:?@:$~ 10 500 , ] -- Raul ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm