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: Generate random numbers with fixed sum and different constraints
Replies: 25   Last Post: Sep 17, 2013 2:28 AM

 Messages: [ Previous | Next ]
 Bruno Luong Posts: 9,822 Registered: 7/26/08
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. .....

> - - - - - - - - -
>
> R = bsxfun(@power,rand(m-1,n),1./(m-1:-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

Date Subject Author
11/14/12 Dmitrey Yershov
11/17/12 Greg Heath
11/17/12 Roger Stafford
11/17/12 Bruno Luong
11/17/12 Roger Stafford
11/18/12 Dmitrey Yershov
11/18/12 Bruno Luong
11/19/12 Bruno Luong
11/19/12 Dmitrey Yershov
11/19/12 Bruno Luong
11/19/12 Dmitrey Yershov
11/19/12 Bruno Luong
11/19/12 Bruno Luong
11/19/12 Roger Stafford
11/20/12 Bruno Luong
11/20/12 Bruno Luong
11/20/12 Roger Stafford
11/21/12 Bruno Luong
11/21/12 james bejon
11/20/12 james bejon
9/17/13 JS Hong
9/17/13 JS Hong
11/19/12 David Epstein
11/19/12 Roger Stafford
11/20/12 Bruno Luong
11/17/12 Greg Heath