Re: A83: Help (Random)


[Prev][Next][Index][Thread]

Re: A83: Help (Random)




Linus Akesson wrote:
> 
> First of all, deterministically speaking, there are NO random numbers. If I
> asked you to give me a number, any number, then you are forced to come up with
> a certain number, depending on what electrons are where in your brains. This
> also means that computers cannot produce random numbers either. However
> cryptic an algorithm you use to convert a seed number (f.ex. a timer) into a
> pseudo-random number, there will always be a mathematical formula (that
> probably can be simplified too).

Of course quantum physics says that nothing can be predicted completely
accurately since particle motion is random.

> What I am trying to say is that there's no use in writing complex
> random-number-generating routines, as the numbers they generate wouldn't be
> _really_ random anyway. Actually, adding 1 to the last "random" number is
> often sufficient! But then the user would spot the algorithm too easy. I'd
> recommend rotating the previous "random" number with some constant, and then
> adding another constant. For an 8 bit number:
> 
> random:      ld   a,(prevrand)
>              rla
>              rla
>              rla
>              add  a,31h
>              ld   (prevrand),a
>              ret
> 
> Want a 16-bit number? Call the function twice!

Just because truly random numbers can't be generated doesn't mean you
can't try.  I would hate to see you write a gambling program, or perhaps
some kind of Monte Carlo simulation.  The randomness of a particular
generator can in fact be determined by many factors, including its
period, or the time it takes to repeat itself.  I would expect this type
of algorithm to have a very short period, probably less than 1000.  The
numbers won't be very "random" either.

Here's a web site on one of the newest and best random number
generators, and its quite speedy, too.

http://www.math.keio.ac.jp/~matumoto/emt.html

-- 
John Kugelman.  kugelman@mnsinc.com

I believe we can change anything.
I believe in my dream.
    - Joe Satriani


Follow-Ups: References: