
Re: Generate random numbers with fixed sum and different constraints
Posted:
Nov 17, 2012 6:22 AM


"Dmitrey Yershov" <pierrevanstulov@mail.ru> wrote in message <k80995$9eo$1@newscl01ah.mathworks.com>... > Hello. I need to generate nonnegative rundom numbers sum of which is equal to 1. Each number xi is constrained: ai<=xi<=bi. How can I do this? Similar question was solved here > > http://www.mathworks.com/matlabcentral/fileexchange/9700 > > but in this alghorithm a<=xi<=b (a and b are the same for all xi). Any ideas?
Z = a + (ba)*rand(m,n);
sumZ = repmat(sum(Z),m,1);
I'll let you figure out the rest.
Hope this helps
Greg

