82 470
Assignments Done
100%
Successfully Done
In January 2020

# Answer to Question #45329 in MatLAB | Mathematica | MathCAD | Maple for Akshay Joshi

Question #45329
The Birthday Problem: The birthday problem is stated as follows: If there is a group of n people in a room, what is the probability that two or more of them having same birthday? It is possible to determine answer to this question by simulation. (Hint: You can generate random dates, n times and determine the fraction of people who born in a given day). Write a function that determines the answer to this question by simulation. The program you write can take n as the input and prints out the probability that two or more of n people will have the same birthday for n=2,3,4…. 40
1
2014-08-27T09:58:35-0400
``close all; clear all; clc;date_min = datenum([1960 1 1]);             % start datedate_max = floor(now);                      % current dateN = 40;P = zeros(1,N-1);for n=2:N   date_r = randi([date_min date_max], 1, n);     % random day       date_r_d = datevec(date_r);                    d = date_r_d(:,3);       m = date_r_d(:,2);        c = 0;       for i = 1:n            for j = 1:n                if m(i) == m(j) &amp;&amp; d(i) == d(j) &amp;&amp; i ~= j                    c = c + 1;                end            end        end        P(n-1) = c/n;endP``

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!