Path: news.mathworks.com!not-for-mail
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$1@fred.mathworks.com>
References: <i22vhv$frn$1@fred.mathworks.com> <i24er8$7qs$1@fred.mathworks.com> <Jbj1o.16614$Bh2.16201@newsfe04.iad> <i24fnn$6pu$1@fred.mathworks.com> <YKj1o.92592$Lj2.82402@newsfe05.iad> <i24i60$gfp$1@fred.mathworks.com> <i24nq0$oat$1@fred.mathworks.com> <i24pio$k5f$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1279652779 5400 172.30.248.37 (20 Jul 2010 19:06:19 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 20 Jul 2010 19:06:19 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:654691

"Matt J " <mattjacREMOVE@THISieee.spam> wrote in message <i24pio$k5f$1@fred.mathworks.com>...
> 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