From: Matt J on
"jay " <ssjzdl(a)gmail.com> wrote in message <i22vhv$frn$1(a)fred.mathworks.com>...
> 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
==========

A=cumsum(rand(1,5))/5;
From: Walter Roberson on
Matt J wrote:
> "jay " <ssjzdl(a)gmail.com> wrote in message
> <i22vhv$frn$1(a)fred.mathworks.com>...
>> 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
> ==========
>
> A=cumsum(rand(1,5))/5;

I'm relatively sure that Roger showed in an earlier thread that that
approach produces biased results.
From: Matt J on
Walter Roberson <roberson(a)hushmail.com> wrote in message <Jbj1o.16614$Bh2.16201(a)newsfe04.iad>...

> >
> > A=cumsum(rand(1,5))/5;
>
> I'm relatively sure that Roger showed in an earlier thread that that
> approach produces biased results.
================

Did the OP require that there not be bias?
From: Matt J on
Walter Roberson <roberson(a)hushmail.com> wrote in message <Jbj1o.16614$Bh2.16201(a)newsfe04.iad>...

> >
> > A=cumsum(rand(1,5))/5;
>
> I'm relatively sure that Roger showed in an earlier thread that that
> approach produces biased results.
=======

Another possibility. Still biased?

A=cumsum(rand(1,6));
A=A/sum(A);
A(end)=[];
From: Walter Roberson on
Matt J wrote:
> Walter Roberson <roberson(a)hushmail.com> wrote in message
> <Jbj1o.16614$Bh2.16201(a)newsfe04.iad>...
>
>> > > A=cumsum(rand(1,5))/5;
>>
>> I'm relatively sure that Roger showed in an earlier thread that that
>> approach produces biased results.
> ================
>
> Did the OP require that there not be bias?

You are correct, the OP placed no such restriction in the question,
including not requiring that the random numbers be drawn from a uniform
random distribution.

In terms of what the OP demonstrably asked for, the following would also
be valid:

((0:4) + rand(1,5)) ./ 5

There was, however, some ambiguity in the OP's phrasing.

First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5 6 7
Prev: Speed bottleneck
Next: Error message for rayleighchan