Chapter 2: urn probabilities #2

To create this simulation, we first write:

REPS=100000; %number of repetitions in the simulation

Nballs=138; %number of balls

URN=1:Nballs; %define the urn

D=nan(REPS,3); %initialize a data matrix with NaN values

where we have re-defined Nballs and D because we are dealing with the second urn, and because each simulation run will contain 3 draws. The for-loop that executes the simulation is:

for n=1:REPS,

for nn=1:3, Unow=URN(randperm(Nballs)); D(n,nn)=Unow(1); end, end

sum(or(or(...

and(D(:,1)>74,and(D(:,2)<=74,D(:,3)<=74)),...

and(D(:,2)>74,and(D(:,1)<=74,D(:,3)<=74))),...

and(D(:,3)>74,and(D(:,1)<=74,D(:,2)<=74)))...

)/REPS