%Here is a script to help you with Exercise 2.1 %p=0.1, n=5,r=0, page 16 of Davis, probability % of an exploration program of 5 holes with no discoveries clear p=0.1; n=5; r=0; nmk=n-r; %cjw's little script to calculate the combination %of two numbers, nCr (Eqn. 1.52, GG313 lecture notes) %note that it might go wrong for large n temp1=max(r,nmk); temp2=min(r,nmk); stop=temp1+0.1; value=1; for i=n:-1:stop; value=value*i; end for i=1:temp2 value=value/i; end %value is the value of nCr value P=value*p^r*(1-p)^(nmk) clear; p=0.1; n=5; r=1; nmk=n-r; temp1=max(r,nmk); temp2=min(r,nmk); stop=temp1+0.1; value=1; for i=n:-1:stop; value=value*i; end for i=1:temp2 value=value/i; end %value is the value of nCr value P=value*p^r*(1-p)^(nmk) %This will help you with Exercise 2.2 clear load balance.dat whos b1=balance(:,1) b2=balance(:,2) subplot(2,1,1) hist(b1); hold on subplot(2,1,2) hist(b2) pause hold off mean1=mean(b1) mean2=mean(b2) %or mean1=sum(b1)/length(b1) mean2=sum(b2)/length(b2) %calculate standard deviation--see help std std(b1) std(b2) %Excerise 2.3 clear load WLYONS.dat whos xcor=WLYONS(:,1); ycor=WLYONS(:,2); por=WLYONS(:,3); h20=WLYONS(:,4); thick=WLYONS(:,5); %you will need the function normcdf for this problem (1-4) clf hist(por,20) pause %next part, while you could use a chi-2 test, do this problem instead using %equation 2.42 for a %population with mean 15% and standard deviation (of the population) %of 5%, get the p value %the next part, test the equality of the means hist(thick,20) i1=0; i2=0; for i=1:length(por) if (thick(i)< 30); i1=i1+1 por1(i1)=por(i); else i2=i2+1 por2(i2)=por(i); end end subplot(2,1,1) hist(por1,20); hold on subplot(2,1,2) hist(por2,20); pause; clf