I want to estimate, for groups of x persons, the probability that at least two of them have the same birthday. I want to repeat this process 1000 times. So I'm looking for the number of 1000 random birthday lists that contain the same birthday. (in other words, I need the probability)
Let' say a function which calculates a random birthdays is ($x$ can be from $x=1$ to $x=365$)
birthdays[x_] := RandomInteger[{1, 365}, x]
is my answer. Take x=25 and determine whether birthdays[x]
contain equal numbers.
bday1 = birthdays[25]
Length[bday1]
ubday1 = Union[bday1]
Length[ubday1]
is my answer.
This is my answer so far; and I don't know whether its correct or not.
birthprob[x_] := Count[Table[RandomInteger[{1, 365}, x], {1000}],
Could someone help me?
Comments
Post a Comment