From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: how to generate random variable with constraint?
Date: Tue, 20 Jul 2010 19:06:19 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 16
Message-ID: <i24s3b$58o$>
References: <i22vhv$frn$> <i24er8$7qs$> <Jbj1o.16614$Bh2.16201@newsfe04.iad> <i24fnn$6pu$> <YKj1o.92592$Lj2.82402@newsfe05.iad> <i24i60$gfp$> <i24nq0$oat$> <i24pio$k5f$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1279652779 5400 (20 Jul 2010 19:06:19 GMT)
NNTP-Posting-Date: Tue, 20 Jul 2010 19:06:19 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: comp.soft-sys.matlab:654691

"Matt J " <mattjacREMOVE@THISieee.spam> wrote in message <i24pio$k5f$>...
> Roger- You're right. I had a mistake. What I really meant to give was this:
> A=cumsum(rand(1,6)); A=A/A(end); A(end)=[];
> I reran John's 2D test on this and find that it covers the correct triangular area, though slightly less uniformly than the sorting method.
> Again, though, for me, this was all just an exercise in seeing if we could get something nearly as good using cheaper summations instead of sorting.
- - - - - - - - - - -
  Matt I checked out the two-dimensional plot for your revised code:

 A=cumsum(rand(1,6)); A=A/A(end); A(end)=[];

It does cover the correct triangle.  However it is grossly inaccurate to say that it is only "slightly less uniform than the sorting method."  The probability area density actually drops down to zero at each corner of that triangle, whereas in a good solution it ought to be a uniform plateau throughout the entire triangle's area.  This disparity would continue to worsen as the number of variables increases, though unfortunately it is difficult to illustrate this fact with plots.

Roger Stafford