How do I get random #s?
Doug Gwyn
gwyn at smoke.BRL.MIL
Tue Feb 7 03:01:05 AEST 1989
In article <16034 at tiger.oxy.edu> bagpiper at oxy.edu (Michael Paul Hunter) writes:
>How about a quick hack at a random number generator that is
>kindof-fairly uniorm in [0, 1]. My quick answer is to scale
>rand...but that doesn't seem to be the best quick hack answer
>to me.
I think it is. If you really need extremely good random deviates
then you have a lot of research and hard work to do.
Before somebody mentions the recent CACM article, let me denounce
it as not contributing significantly to this subject.
By the way, I find that [0,1) (i.e. including 0 but excluding 1)
is a more useful range. The obvious implementation using the
previously-posted my_rand() is:
extern int my_rand(); /* uniform integer in [0,32767] */
double my_unif() { return my_rand() / 32768.0; } /* [0.0,1.0) */
More information about the Comp.lang.c
mailing list