🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #4996

Re: Random Numbers

#4996
From: Michael D Mellinger
Date: Mon, 04 Mar 1991 05:24
24 lines
1425 bytes
In article <1991Mar2.201214.22848@herald.usask.ca> reeves@dvinci (Malcolm Reeves) writes:


   (1) Must the generator be able to produce an identical sequence on request?
   (2) Must the code be portable from machine to machine and give the same
       results?
   (3) What tests of randomness must the numbers pass?
   (4) What distribution do you want the numbers to have?

I just need a random number between 1 and 100 so I can index an array
that holds the result.  For example, if the number is random then I
should have a 40% chance of picking the number 20 if I pick a random
number b/w 1 and 5.

index   1   2   3    4   5
value   1  20  20   34   1

In other words, I know the exact distribution.  Seeding srand() with
the value of the clock should work.  Does anyone see any problems with
this?  Another question...next message.


-Mike
Technical Details
Message-ID: <y72G9jw?@cs.psu.edu>
Path: arc1-ca.pugleaf.net!utzoo!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!psuvax1!news
References: <r7bGl?wz@cs.psu.edu> <1991Mar2.201214.22848@herald.usask.ca>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!psuvax1!news
From: melling@cs.psu.edu (Michael D Mellinger)
Newsgroups: comp.os.msdos.programmer
Subject: Re: Random Numbers
Message-ID: <y72G9jw?@cs.psu.edu>
Date: 4 Mar 91 05:24:13 GMT
References: <r7bGl?wz@cs.psu.edu> <1991Mar2.201214.22848@herald.usask.ca>
Sender: news@cs.psu.edu (Usenet)
Distribution: comp
Organization: Penn State Computer Science
Lines: 24
In-Reply-To: reeves@dvinci's message of Sat, 2 Mar 91 20:12:14 GMT
Nntp-Posting-Host: sunws5.sys.cs.psu.edu