swarm-modeling
[Top][All Lists]
Advanced

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

Question on partitioning a set of agents.


From: Jason Alexander
Subject: Question on partitioning a set of agents.
Date: Fri, 06 Aug 1999 22:01:53 -0700

For one of my models I need to randomly partition a set of agents
(stored as a list) into N disjoint classes, where each class is
equiprobable.

Are there any implicit biases in the following procedure that I'm
unaware of?  (It seems okay to me.)

Let L denote the list of agents.
Assume RandomFloat() return a number between 0 and 1.

for i=1 upto N-1 {
  loop over L {
     if RandomFloat < 1/N {
        remove current agent from L
        insert current agent into class i
     }
  }
}
Copy remaining agents from L into class N.


Cheers,

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]