# Mental Exercise

Magnus Danielson magda at it.kth.se
Thu Mar 13 07:37:50 CET 1997

```>>>>> "S" == Synthfool  <Synthfool at aol.com> writes:

S> Josh says randomly-
>> I though about how one might do this using analog circuitry or
>> discrete logic, but to me the problem just seems to lend itself to a
>> microprocessor design.

>> So, the question is: how would it be possible to implement this
>> randomness feature using analog and/or discrete logic?

S> I've always wondered about how to get true randomness out of a wholly digital
S> machine based on 1's and 0's. Is it really possible or will a pattern
S> eventually evolve.
S> Back in the days of the Apple II, I would look thru a rom and xor it with
S> other data like the game port and cassette input.

As allways in computer programing problems you can say "It's in
Knuth's book(s)" and I will of course do this myself :)

But just to really show that it IS in Dolnad Knuth's "The Art of
Computer Programing" I will point to Vol.2 Chapter 3. This chapter is
both a thourough and deligthfull reading on the topic of generating
random numbers.

There is many ways of doing it in real life, and one common way to do
it is to use shiftregisters and exlusive or gates or possibly
multiplications and additions to get a random number. The trick to
avoid circularity and patterns is to use long sequences. It is quite
cheap to do a sequence so long that even if you tick megahertzes on
the shift register you will need over a century to repeat the
sequence. This technique is used in CDMA radio to scramble the data.
You can use various external sources to peek the seed, which will give
the 'phase' of the repeating pattern...

Cheers,
Magnus

```