www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/08/14/03:29:48

Date: Sun, 14 Jul 1996 12:28:05 +0000 ( )
From: Gurunandan R Bhat <grbhat AT unigoa DOT ernet DOT in>
To: stwand07 AT uctvms DOT uct DOT ac DOT za
Cc: djgpp AT delorie DOT com
Subject: Re: rand(), random() or libg++ Random ?
In-Reply-To: <1996Aug13.140921@uctvms.uct.ac.za>
Message-Id: <Pine.LNX.3.91.960714122217.393A-100000@aditya.unigoa.ernet.in>
Mime-Version: 1.0


On 13 Aug 1996 stwand07 AT uctvms DOT uct DOT ac DOT za wrote:

> Hi
> 
> I am busy working on an optimisation program that makes extensive use of random
> number (stochastic search). I have been using srand(time(NULL)) and rand() to
> give random numbers in the range 0..1, which I then scale as required. I have
> heard that rand() is not very good, so my questions are :
> 1. Is random() any better?
> 2. Are the libg++ Random classes better?
> 
> I need a normal distribution with zero mean, so 'better' refers to these
> criteria.
> 
> Adios
> Mark Wodrich.
> UCT, Cape Town, South Africa.
> 


the reason for not using rand() is most often, a suspicion about the
linear congruential method. if that is true in your case, you might like
to look at generators that do not use the lcm. in particular you might
profit from an algorithm by George Marsaglia which uses some properties of
the fibonacci series. the c code implementing this algorithm, by Jim Butler
is available in the netlib archives. i have used it with satisfaction.

cheers
gurunandan bhat
department of physics
goa university
goa. india


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019