[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 13:49:27 -0700 (PDT) |
David Koelle writes:
> I would suggest that you start generating a number between 0.0 and 1.0, then
> subtract the random value from 1.0 so next time you pick a random number
> between 0.0 and 1.0-random, and so on (essentially, to modify Rule B above:
> "The difference of all elements from 1 is 0")
>
> x = 1.0
> for (i=0; i<n-1; i++) {
> statevector[i] = random number between 0.0 and x;
> x = x - r;
> }
> statevector[n] = x;
I thought of this, but doesn't it tend to bias small values of i over
large values of i? It seems to me that statevector[0] has a greater
chance of being close to 1.0 than statevector[n], since it only takes
a single high "roll of the dice" to set statevector[0] near 1.0, but
it takes n-1 low rolls to get statevector[n] near 1.0
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.
==================================