This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: % end %end %end % %function res = bd2( num_people, num_trials ) %z = starttally; %for trials = 1:num_trials % d = sample(num_people, 1:365 ); %f = any( multiples(d) >= 2); %tally f z; %end % %res = proportion(z); %tallyshared =0; %for i = 1:numsamples % generate birthdays %bdays=floor(rand(1,40)*366) % find if any are shared %uniquedays = unique(bdays); %shared = 1 if there is common bday %shared = length(bdays)~=length(uniquedays); % keep running tally %tallyshared = tallyshared+shared; %end % figure out proportion %proportion = tallyshared/numsamples; %To do this many times just write another for loop and turn proportion %into a vector: % % %for j=1:numtrials ..... %as above except. .... %proportion(j)=tallyshared/numsamples; %end %...
View Full Document
- Spring '08