From: Walter Roberson <>
User-Agent: Thunderbird (Macintosh/20100228)
MIME-Version: 1.0
Newsgroups: comp.soft-sys.matlab
Subject: Re: how to generate random variable with constraint?
References: <i22vhv$frn$> <i2308i$7p$>
In-Reply-To: <i2308i$7p$>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 17
Message-ID: <Ob91o.39684$YX3.15357@newsfe18.iad>
X-Trace: newsfe18.iad 1279598446 (Tue, 20 Jul 2010 04:00:46 UTC)
NNTP-Posting-Date: Tue, 20 Jul 2010 04:00:46 UTC
Date: Mon, 19 Jul 2010 23:00:45 -0500
Xref: comp.soft-sys.matlab:654448

someone wrote:
> "jay " <> wrote in message 
> <i22vhv$frn$>...
>> I need to generate 5 random variables between [0,1], let's say a, b, 
>> c, d, e. The constraint is that a<b<c<d<e. How to make this happen? 
>> Please advise. thanks
> doc rand
> doc sort
> It seems to me that the only way 5 random numbers wouldn't satisfy that 
> constraint is if 2 or more of them are equal.  A very unlikely event.

Roger Stafford has discussed some limitations on generating random 
variables with constraints -- if it is done incorrectly, the values tend 
to cluster towards the middle instead of uniformly distributed. I think 
sorting was okay, but I'd have to find the previous threads to be sure.