home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!gatech!bloom-beacon!eru.mt.luth.se!lunic!sunic!corax.udac.uu.se!corax.udac.uu.se!pem
- From: pem@Minsk.DoCS.UU.SE (Per-Erik Martin)
- Newsgroups: comp.programming
- Subject: Re: Any simple Random Number generators?
- Message-ID: <1992Aug14.104121.29374@corax.udac.uu.se>
- Date: 14 Aug 92 10:41:21 GMT
- References: <13AUG199218224504@judy.uh.edu>
- Sender: news@corax.udac.uu.se
- Organization: Student
- Lines: 28
- In-Reply-To: cscc13@judy.uh.edu's message of Thu, 13 Aug 1992 23:22:00 GMT
-
- In article <13AUG199218224504@judy.uh.edu> cscc13@judy.uh.edu (NAVEED IQBAL) writes:
-
- >I want to know how random numbers are generated.
-
- If you are talking about "pseudo random numbers" (which is the common
- case in programming) you may want to read Donald E. Knuth's "The art
- of computer programming, vol 2", and definitely the article
- "Random number generators: Good ones are hard to find" by Stephen K. Park
- and Keith W. Miller in Communications of the ACM October 1988 (v31n10).
- This article also contains a proposed "minimal standard" generator which
- is simple but yet quite good.
-
- >I want to get a "new" random number everytime I run the program.
-
- You simply "seed" the generator with the system clock when the program
- is started.
-
- >I did download a program to do that from wuarchive but I was wondering
- >if there was a simpler way.
-
- If you're running Unix and C you (usually) have random(3) (good enough)
- and drand48(3) (better but slower), and rand(3) *if* it's an ANSI-C
- library. (Beware of the old Unix rand()!)
-
- --
- |\/|\/|\/| Per-Erik Martin,
- | | |/\| Department of Computer Systems, Uppsala University,
- |/\| | | Email: pem@minsk.DoCS.UU.SE
-