Prev: feather plot help please?
Next: Data at regular interval from non-regular interval using INTERP1
From: Wendy on 27 May 2010 20:52 Hi all, I want to generate 30 random numbers that are between 0 and 1, and these 30 numbers have to add up to 1. Does anyone know how to generate random numbers that add up to a certain value? Thank you in advance, Wendy
From: Walter Roberson on 27 May 2010 20:59 Wendy wrote: > I want to generate 30 random numbers that are between 0 and 1, and these > 30 numbers have to add up to 1. Does anyone know how to generate random > numbers that add up to a certain value? See yesterday's thread (active today as well), "random values".
From: Roger Stafford on 27 May 2010 21:59 "Wendy " <wlq121(a)gmail.com> wrote in message <htn43m$3t0$1(a)fred.mathworks.com>... > Hi all, > > I want to generate 30 random numbers that are between 0 and 1, and these 30 numbers have to add up to 1. Does anyone know how to generate random numbers that add up to a certain value? > > Thank you in advance, > Wendy This is straight out of Wikipedia. r = diff([0;sort(rand(30,1));1]); Roger Stafford
From: Roger Stafford on 27 May 2010 22:08 "Roger Stafford" <ellieandrogerxyzzy(a)mindspring.com.invalid> wrote in message <htn818$6kj$1(a)fred.mathworks.com>... > ....... > r = diff([0;sort(rand(30,1));1]); > ...... Sorry. I meant to write r = diff([0;sort(rand(29,1));1]); Roger Stafford
|
Pages: 1 Prev: feather plot help please? Next: Data at regular interval from non-regular interval using INTERP1 |