[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: NSelect working? -- No (& suggested fixes).
From: |
Rick Riolo |
Subject: |
Re: NSelect working? -- No (& suggested fixes). |
Date: |
Mon, 2 Feb 1998 09:00:53 -0500 (EST) |
Ok, here are a couple of bugs in NSelect (src/simtools/NSelect.m),
and then a couple of suggestions:
1. The RNG call should be:
r = (float) [uniformDblRand getDoubleWithMin:0 withMax: 1.0] ;
(Aside: Is it worth doing a cast to a float?
I would imagine that for many/most modern machines
just leaving it as a double would be just as fast or faster,
especially since the RNG already produced it for us!)
2. I believe that "put" should not be used to add things to
the bCollection (the sample), since (if I understand it)
put *replaces* the member at the index position.
Not only does one not want to do a replace, it just crashes
since for the first sample there is nothing to replace,
so the put causes a core dump with:
*** event raised for error: InvalidIndexLoc
*** function: _i_ListIndex_linked__put_(), file: List_GEN.m, line: 380
*** execution terminating due to error
In fact, I think the index into bCollection is not needed at all,
and instead you can just do addFirst or addLast to it bCollection
directly. Thus the heart of the algorithm is:
while(m < n){
r = (float) [uniformDblRand getDoubleWithMin:0 withMax: 1.0] ;
if( ( ((float)(N - t)) * r) >= ((float)(n - m)) ){
[a next] ;
} else {
m++ ;
[bCollection addLast: [a next]];
}
t++ ;
}
3. I think there should be a way to assign the distribution
object that Select will use (so one can have it in
whatever RNG streams the user wants to use).
4. I think the documentation should mention that the
sample objects will come out in the same order,
just to make sure the user doesn't expect to
get sampled objects in a random order.
5. I think the documentation should mention that things are
added to bCollection (if that is the intention),
or bCollection should have a removeAll sent to it.
(I prefer the former...the user should empty it if desired.)
- r
Rick Riolo address@hidden
Program for Study of Complex Systems (PSCS)
4068 Randall Lab
University of Michigan Ann Arbor MI 48109-1120
Phone: 313 763 3323 Fax: 313 763 9267
http://www.pscs.umich.edu/PEOPLE/rlr-home.html
On 1 Feb 1998, Marcus G. Daniels wrote:
> Date: 01 Feb 1998 16:03:11 -0800
> From: Marcus G. Daniels <address@hidden>
> To: address@hidden
> Cc: Swarm-Support <address@hidden>, address@hidden
> Subject: Re: NSelect working?
>
> >>>>> "RLR" == Rick Riolo <address@hidden> writes:
>
> RLR> Do I need to do something else to use NSelect? Or is there a bug
> RLR> (!) in there somewhere? (From the message it looks like NSelect
> RLR> is maybe not using the random lib stuff correctly...)
>
> Yeah, I agree. It seems the call to getDoubleSample in NSelect.m needs
> to be replaced with "getDoubleWithMin:0 withMax: 1.0".
>
==================================
Swarm-Support is for discussion of the technical details of the day
to day usage of Swarm. For list administration needs (esp.
[un]subscribing), please send a message to <address@hidden>
with "help" in the body of the message.
==================================