Re: The randomfunction
From: Darrell Grainger (darrell_at_NOMORESPAMcs.utoronto.ca.com)
Date: 11/29/03
- Next message: Espen Amundsen: "Re: The randomfunction"
- Previous message: dfg: "Re: c# - what is it for?"
- In reply to: Espen Amundsen: "The randomfunction"
- Next in thread: Espen Amundsen: "Re: The randomfunction"
- Reply: Espen Amundsen: "Re: The randomfunction"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: Espen Amundsen: "Re: The randomfunction"
- Previous message: dfg: "Re: c# - what is it for?"
- In reply to: Espen Amundsen: "The randomfunction"
- Next in thread: Espen Amundsen: "Re: The randomfunction"
- Reply: Espen Amundsen: "Re: The randomfunction"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|