swarm-support
[Top][All Lists]
Advanced

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

Re: SimpleGenerator methods: what is getThinDoubleSample?


From: Sven N. Thommesen
Subject: Re: SimpleGenerator methods: what is getThinDoubleSample?
Date: Wed, 17 Oct 2001 11:29:51 -0500

At 08:44 AM 10/17/01, Paul Johnson wrote:

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?

A call to get an unsigned random value returns 32 bits of "randomness". An IEEE double has 53 bits of mantissa, so a single unsigned int cannot fill all those bits. When I created the random library in its present form I therefore allowed you to choose (via a compilation switch in the random library) whether you are satisfied with the precision you get from using a single unsigned to fill the double, or if you want to fill all of the 53 bits, using two unsigneds. You decide what's needed for the purposes you have in mind.

As you observe, the default of using two calls per doublesample does take more time. You may recompile to speed things up.

I'd advise that if you are going to add more distribution objects to the library, you should make the new ones able to use either a single or a double call to getUnsignedSample, to maintain uniform functionality across the library.

Sven Thommesen


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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]