swarm-modeling
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Randomly initializing a N-element vector


From: Russell J. Abbott
Subject: Re: Randomly initializing a N-element vector
Date: Sat, 9 Oct 1999 14:06:46 -0700

Off the top of my head, how about this:

Generate N-1 random numbers between 0 and 1.  Sort them.
Preceed the first by 0 and follow the last by 1.
Take the differences between the elements in the extended
sorted result.  Permute those differences randomly.

Each difference is between 0 and 1.  The total sums to 1.

-- Russ Abbott


|I need to randomly initialize a N-element vector such that
|
| (a) every element is between 0 and 1
| (b) the sum of all elements is 1



                  ==================================
   Swarm-Modelling is for discussion of Simulation and Modelling techniques
   esp. using Swarm.  For list administration needs (esp. [un]subscribing),
   please send a message to <address@hidden> with "help" in the
   body of the message.
                  ==================================


reply via email to

[Prev in Thread] Current Thread [Next in Thread]