Article View: rec.puzzles
Article #2590RANDOM NUMBERS ON A COMPUTER
From: Trevor German
Date: Thu, 07 Jan 1993 19:46
Date: Thu, 07 Jan 1993 19:46
48 lines
2473 bytes
2473 bytes
Someone wants to know hos to create random numbers on a computer.
This sounds trivial but it is not. First you need a good definition
of a random number. The definition required is as follows.
1. The number shall be contained within a range, say 0 - 255
2. The probability of selecting and number at any time will
be 1:256.
3. No sequencies shall exist, ever.....
If an algorithm is used than sooner or later some condition will
be met that restarts the sequence. This is why these routines are
usually called pseudo-random generators. Also, they very often
favour some numbers and therefore the selection distribution is not
even.
Rather than develop complex routines than generate very long
sequencies of numbers a common approach is to use a relatively
short but uniform repeating sequence and use an external influence
to index into it. For games etc this external influence is time
between user actions or keystrokes. If a fast clock is used, say
1 MHz then something that approaches random selection is produced.
Kinda like those electronic dice that are simply counters that run
when you press the button and stop when you let go. Its random
because you can't accuratly control your finger within the scale
of the clock.
However, when being used for a completely internal purpose such as
providing numbers for a number-cruncher where the time between
selections is fixed and repeating then the resultant numbers
produced are not random. Sometimes, though, thats exactly what
you want, to be able to repeat the experiment.
Hardware random number generation can be done using something that
counts random events, like the atmospheric noise froma tuned out
radio etc.
------------------------------------------------------------------
--
>| "Only average people | Trevor J German BSc |<
>| never make mistakes." | NCR, Waterloo, Ontario |<
>| tjgerman@53iss6.Waterloo.NCR.COM | Canada. |<
Technical Details
Message-ID:
<10358@ncrwat.Waterloo.NCR.COM>Path:
arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!swrinde!emory!ncratl!ncrhub2!ncrwat!53iss6!tjgermanShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!swrinde!emory!ncratl!ncrhub2!ncrwat!53iss6!tjgerman From: tjgerman@53iss6.Waterloo.NCR.COM (Trevor German) Newsgroups: rec.puzzles Subject: RANDOM NUMBERS ON A COMPUTER Message-ID: <10358@ncrwat.Waterloo.NCR.COM> Date: 7 Jan 93 19:46:16 GMT Sender: news@ncrwat.Waterloo.NCR.COM Organization: Imaging Systems Division, NCR Corp, Waterloo, Ont., CANADA Lines: 48