[Haskell-cafe] Performance question

Brandon S. Allbery KF8NH allbery at ece.cmu.edu
Sat Feb 28 16:01:49 EST 2009


On 2009 Feb 27, at 1:50, Ketil Malde wrote:
> Lennart Augustsson <lennart at augustsson.net> writes:
>> C's rand() function is very bad and should never be used really.
>
> On Linux (really GNU libc, I suppose) it is the same as random().  But
> for portability, one is encouraged to spend the two extra letters.  I
> don't understand the details, but I think the Mersenne twister is much
> better in any case.

Yes, much better than any LC PRNG including rand(), random(), and the  
System V/POSIX lrand48() family.  That said, Linux making rand() ==  
random() breaks portability in the case where you want a repeatable  
stream for testing purposes; as usual, Linux chucks portability out  
the window at any opportunity.  (Sadly, POSIX permits this because of  
POSIX implementations for non-Unix hosts, although it does include a  
fixed-behavior PRNG as documentation for this case.)

-- 
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery at kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university    KF8NH


-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 195 bytes
Desc: This is a digitally signed message part
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090228/fc983be2/PGP.bin


More information about the Haskell-Cafe mailing list