
Re: Generate random numbers with fixed sum and different constraints
Posted:
Nov 20, 2012 1:53 AM


"Roger Stafford" wrote in message <k8ee8q$k6f$1@newscl01ah.mathworks.com>... > "Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <k8dakj$39u$1@newscl01ah.mathworks.com>... > > It seems to me this task > > w = randfixedsum(m,n,1,0,1) > > can be optimized as well. ..... >          > Yes, I agree, Bruno; 'randfixedsum' is rather cumbersome to use just for a single simplex. How about this instead: > > R = bsxfun(@power,rand(m1,n),1./(m1:1:1)'); > X = cumprod([ones(1,n);R]).*[ones(m,n)[R;zeros(1,n)]]; > > Roger Stafford
Really cool Roger! I would love if you could share the justification of this formula.
Bruno

