% Pset 3 Question 1: clear all % Probability cargo transported by each method: p_land=.5; p_sea=.2; p_air=.3; % out of land transportation: p_land_highway=.6; p_land_rail=.4; % total probabilities for land transpo p_highway=p_land*p_land_highway; p_rail=p_land*p_land_rail; % probability of damaged cargo damage_highway=.12; damage_rail=.03; damage_sea=.05; damage_air=.02; % what percentage of cargo is undamaged? % if damaged, what is probablilty shipped by each method (land, sea, air) nrep=100000; damaged=zeros(nrep,2); for i=1:nrep shipment=rand(1,1); if shipment=p_highway&shipment<(p_highway+p_rail) cargo=rand(1,1); damaged(i,1)=cargo=(p_highway+p_rail)&shipment<(p_highway+p_rail+p_sea) cargo=rand(1,1); damaged(i,1)=cargo=(p_highway+p_rail+p_sea) cargo=rand(1,1); damaged(i,1)=cargo