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: jalex
Subject: Re: Randomly initializing a N-element vector
Date: Fri, 8 Oct 1999 14:14:50 -0700 (PDT)

Sven N. Thommesen writes:

> >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
> 
> 
> Umm... give each element a random value between 0.0 and 1.0 (any generator 
> will give you that), then scale (divide) all elements by the sum of the 
> elements drawn?

This occured to me as well, but I managed to convince myself (perhaps
erroneously) that it didn't give a _uniform_ sampling of the space.

Consider the simple case when N=3.  The simplex space I'm sampling
from is triangular region T in the first octant between (0,0,0),
(1,0,0), (0,1,0), and (0,0,1).  While the method described does give a
1-1 mapping from the unit cube into T, doesn't this deform the cube in
a way which biases the sampling?  I'm not great at visualizing
diffeomorphisms, but as the cube gets squashed into the region T, it
seems that the volume of the cube doesn't evenly spread out over the
region T, which is what needs to happen for the sampling to be
uniform.

If I'm wrong, great -- this method is fast and easy to implement.

Thanks,

Jason


                  ==================================
   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]