Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Simulation of 5 Random Variables with Sum Constraint
Replies: 8   Last Post: Apr 3, 2013 3:05 AM

 Messages: [ Previous | Next ]
 Siddhartha Posts: 6 Registered: 11/19/12
Simulation of 5 Random Variables with Sum Constraint
Posted: Mar 27, 2013 4:50 PM

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));

subplot(2,2,1), hist(e,cole);
subplot(2,2,2), hist(e(e<98),colf);
subplot(2,2,3), ecdf(e);
subplot(2,2,4), ecdf(e(e<98));

Date Subject Author
3/27/13 Siddhartha
3/27/13 Steven Lord
3/27/13 Siddhartha
3/28/13 Steven Lord
3/28/13 Bruno Luong
3/28/13 Siddhartha
3/28/13 Bruno Luong
4/1/13 Siddhartha
4/3/13 Bruno Luong