Hi
I have two different procedures to do, precedure A has 0.8 probabilty and B has 0.2. How can I create a parameter to select those procedures based upon them probability in case of iterative process ( I am doing this thousands of times)?
I have seen some answers here but not so sure that I am doing it right. Two solution are below but I got suspisous its correct when run it a multiple of 10 times where the 1's or 2's werent exactly showing at 80%,20% everytime for the first solution and the use of 'true' in the second one .
I am not expert instastics and probabilty so just asking if that correct way of doing it and is the result ok or not .
% solution 1
out = randsrc(1,1,[1,2;0.8,0.2])if out==1 Procedure A;else procedure Bend% solution2
p=[1 2];y = randsample(p,1,true,[0.8,0.2])
Best Answer