[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SimpleGenerator methods: what is getThinDoubleSample?
From: |
Paul E Johnson |
Subject: |
SimpleGenerator methods: what is getThinDoubleSample? |
Date: |
Wed, 17 Oct 2001 08:44:48 -0500 |
I'm making a class that generates random numbers from some miscellaneous
distributions, such as Weibul, and to do that I'm using algorithms from
the GNU scientific library and grafting them into Objective-C using
Swarms random generators. As I do this, I am looking at the Protocol
SimpleGenerator and I see these methods (descriptions from docs
included):
- (float)getFloatSample
The getFloatSample method returns a random floating point number of
size float, uniformly distributed in the range [0.0, 1.0). It uses 1
call to -getUnsignedSample to fill the mantissa.
- (double)getThinDoubleSample
The getThinDoubleSample method returns a random floating point
number of size double, uniformly distributed in the range [0.0, 1.0). It
uses 1 call to -getUnsignedSample to fill the mantissa.
- (double)getDoubleSample
The getDoubleSample method returns a random floating point number
of size double, uniformly distributed in the range [0.0, 1.0). It uses 2
calls to -getUnsignedSample to fill the mantissa.
Now, the question. It appears to me that "getDoubleSample" takes twice
as long as the others, becuase it uses 2 calls to fill the mantissa.
getThinDoubleSample does not. getFloatSample does not either.
So, if one had a program with lots and lots and lots of random number
draws, one could conceivably make it twice as fast by using floatSample
or ThinDoubleSample, correct? What problems could flow from this usage?
Example context. Agents only do something if the draw on a uniform [0,1)
is greater than 0.7. They do this many many times.
--
Paul E. Johnson email: address@hidden
Dept. of Political Science http://lark.cc.ukans.edu/~pauljohn
University of Kansas Office: (785) 864-9086
Lawrence, Kansas 66045 FAX: (785) 864-5700
==================================
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.
- SimpleGenerator methods: what is getThinDoubleSample?,
Paul E Johnson <=