If there is a group of n people in a room, what is the probability that two or more of them have the same birthday?
    5 views (last 30 days)
  
       Show older comments
    
If there is a group of n people in a room, what is the probability that two or more of them have the same birthday? It is possible to determine this question by simulation. Write a function that calculates the probability that two or more of n people will have the same birthday, when n is a calling argument.
3 Comments
  Image Analyst
      
      
 on 16 Mar 2022
				If X is a date, then is N also a date?  So what sense does it make to divide two dates?
Answers (2)
  Image Analyst
      
      
 on 31 Aug 2014
        As this is most likely a homework problem (and I've tagged it as such), I'll just give you some hints.
n = 30;
birthdays = randi(365, n, 1)  % Get list of birthdays out of possible 365 days per year.
counts = histc(birthdays, 1:365) % Count how many people have each birthday.
Put the above in a loop and do it, say, a million times to find the probability that max(counts) >= 2. Try different n also.
0 Comments
  Roger Stafford
      
      
 on 31 Aug 2014
        The probability, P, (in a non-leap year) is:
P = 1 - prod((365:-1:365-n+1)./repmat(365,1,n));
0 Comments
See Also
Categories
				Find more on Birthdays in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



