Let's say I have 5 random variables that are discrete. Each one of them can possess a low, base and high value somewhere between 15 and 35. I know their sum can never exceed 98. What's the best way to simulate this? Is the rejection method good? The sudden drop in the pdf of the sum bothers me, not sure if that's right, but it maybe.
n = 5; a(n,3) = 0; for i = 1:n a(i,1:3) = [100/(1.5*n)+(-1)^fix(rand)*rand*(100/(2*n)) 100/(1.1*n)+(-1)^fix(rand)*rand*(100/(2*n)) 100/(0.8*n)+(-1)^fix(rand)*rand*(100/(2*n))]; end
d = lhsdesign(n,10000);
e = 0; b(1,10000)=0; for i = 1:n b(d(i,:)<0.3) = a(i,1); b(d(i,:)>0.7) = a(i,3); b(b==0) = a(i,2); e = e + b; end
f = e(e<98); [~,cole] = size(unique(e)); [~,colf] = size(unique(f));