Re: The randomfunction

From: Darrell Grainger (darrell_at_NOMORESPAMcs.utoronto.ca.com)
Date: 11/29/03


Date: 29 Nov 2003 01:51:24 GMT

On Fri, 28 Nov 2003, Espen Amundsen wrote:

> Hi
>
> Ive ofte used the randomfunction in different languages but Ive never
> understood how it works. As I see it, truly randomness should be impossible;
> so I just have to know how the randomfx works. Does anyone have the
> sourcecode(any language) or can tell me how thats done?

You are correct that truly random number generators would be impossible in
a programming language. Most languages will use a mathematical formula to
generate a sequence of numbers. Most will use a linear congruent method.
For example:

        x' = (a*x + c) % m

where x is the previous number in the sequence, x' is the next number in
the sequence, a, c and m are set values. The idea is that if you choose a
and c wisely, the sequence will be the maximum length before repeating.
For example, if x is an 8 bit char then the sequence will repeat after all
256 numbers are use.

-- 
Send e-mail to: darrell at cs dot toronto dot edu
Don't send e-mail to vice.president@whitehouse.gov


Relevant Pages

  • Re: The randomfunction
    ... > Ive ofte used the randomfunction in different languages but Ive never ... Linear-Congruential Pseudo-Random Number Generators (LCPRNGs) are ...
    (comp.programming)
  • Re: The randomfunction
    ... Found some more info about randomness at ... >> Ive ofte used the randomfunction in different languages but Ive never ... Most languages will use a mathematical formula to ... > generate a sequence of numbers. ...
    (comp.programming)
  • The randomfunction
    ... Ive ofte used the randomfunction in different languages but Ive never ... sourcecodeor can tell me how thats done? ...
    (comp.programming)
  • Re: A taxonomy of types
    ... Before a representation is practical I think we need a taxonomy (so we ... dynamic typing or type inference and most languages have rules ... Target domain of reference ... Sequence of component types and names ...
    (comp.lang.misc)
  • Re: mottainai
    ... but still a valid prediction. ... The assumption that sequence determines function but that function ... For example, considere cytochrome c. ... > languages are generally accepted by all linguists, ...
    (sci.lang.japan)

Loading