Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uflorida!ukma!rutgers!cmcl2!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn ) Newsgroups: comp.lang.c Subject: Re: How do I get random #s? Message-ID: <9600@smoke.BRL.MIL> Date: 6 Feb 89 17:01:05 GMT References: <19415@dhw68k.cts.com> <9570@smoke.BRL.MIL> <16034@tiger.oxy.edu> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 18 In article <16034@tiger.oxy.edu> bagpiper@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) */