Problem5_24

# Problem5_24 - % end %end %end % %function res = bd2(...

This preview shows pages 1–2. Sign up to view the full content.

% PORGRAM Problem5_24.m % % This program solves problem 5.24 in Chapman (2008). % Derivative of a function. % % Define Variables: % dx - brief description with units %dx - brief description with units % % % %dx - brief description with units % Austin Jones % CVEN 302-501, Spring 2011 % %numberofpeople=5000; % %day=randi(365,numberofpeople,1); % %for i=1:365 %amount = find(day==i); %count(i) = size(amount,1); %end % %n=1:1:numberofpeople; % %for j=1:numberofpeople % birthday=day(j) % amount = find(day==birthday) %if j= %probablitity = % %for j=1:5000 %for n=2:1:40 %probability=zeros(40,1); nt=5000; %number of trials n for n=2:40 for i=1:nt birthdays=randi(365,1,n); notshared=unique(birthdays); shared = length(birthdays)~=length(notshared); probability(i) = shared; end e stat(n)=sum(probability)/nt; end stat(2 clear all c % for i=1:n %amount = find(day==i) %count(i)=size(amount,1)/n

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the 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) &gt;= 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

## Problem5_24 - % end %end %end % %function res = bd2(...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online