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 18:23:20 +0000 (UTC)
Organization: Xoran Technologies
Lines: 15
Message-ID: <i24pio$k5f$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>
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 1279650200 20655 172.30.248.37 (20 Jul 2010 18:23:20 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 20 Jul 2010 18:23:20 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1440443
Xref: news.mathworks.com comp.soft-sys.matlab:654671

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <i24nq0$oat$1@fred.mathworks.com>...

> - - - - - - - - -
>   Matt, I'm in agreement with John and Walter on this.  Your two solutions are not good ones to give as an answer even if Jay did not give specific details as to the desired distribution.
> 
>   For example in your second method with five variables it is impossible for the fifth one to exceed 1/2 even though doing so would easily be compatible with Jay's constraint.
=========

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.