S=10; %Number of simulation rounds %x is now the random number representing orders p=[.1 .4 .3 .2]; %PMF for x P=[.1 .5 .8 1]; %CDF for x X=[0 1 2 3]; %Possible values of x %a) Sample=zeros(S,1); %Initialize the sample vector %continue from here