Randomness

From Maze

(Difference between revisions)
Jump to: navigation, search
(→Computational Randomness in Aesthetic Design)
(→The Commodore 64's RND Function)
Line 118:Line 118:
[[Image:10print-startup-canonical.png|160px|thumb|The first page of output from 10 PRINT when run immediately after startup.]]
[[Image:10print-startup-canonical.png|160px|thumb|The first page of output from 10 PRINT when run immediately after startup.]]
−
RND is, like most computational sources of randomness, a pseudo-random number generator. While there may be no apparent pattern between any two numbers, each number is generated based on the previous one using a deterministic process. When the first number is the same, the entire sequence will always be the same. In the case of the Commodore 64, this is particularly important because the same seed and thus the same first number is set startup. This means that, when RND(1) is invoked immediately after startup, or before any other invocation of RND, it will always produce the same result: 0.185564016. The next invocation will also be the same, no matter what Commodore 64 is used or how long the system has been on. The next invocation -- and all others -- will also be the same. Since the sequence is deterministic, the pattern produced by the 10 PRINT program typed in and run as the first program is always the same, on every computer or well-functioning emulator.
+
RND is, like most computational sources of randomness, a pseudo-random number generator. While there may be no apparent pattern between any two numbers, each number is generated based on the previous one using a deterministic process. When the first number is the same, the entire sequence will always be the same. In the case of the Commodore 64, this is particularly important because the same seed and thus the same first number is set at startup. This means that, when RND(1) is invoked immediately after startup, or before any other invocation of RND, it will always produce the same result: 0.185564016. The next invocation will also be the same, no matter what Commodore 64 is used or how long the system has been on. The next invocation -- and all others -- will also be the same. Since the sequence is deterministic, the pattern produced by the 10 PRINT program typed in and run as the first program is always the same, on every computer or well-functioning emulator.
When called on ''any'' positive number, as when RND(1) is invoked in 10 PRINT, RND produces the next number in this sequence. RND(8), RND(128), or RND(.333) do exactly the same as RND(1). However, RND has two other modes besides the one used in 10 PRINT. The second is stopwatch-based: when RND(0) is called, the clock time since the computer was powered on is used in generating a new seed, meaning that if RND(0) replaces RND(1), each run 10 PRINT at a different second should generate a different output. After a single call to RND(0), subsequent calls to RND(1) will continue generating numbers in that new sequence.
When called on ''any'' positive number, as when RND(1) is invoked in 10 PRINT, RND produces the next number in this sequence. RND(8), RND(128), or RND(.333) do exactly the same as RND(1). However, RND has two other modes besides the one used in 10 PRINT. The second is stopwatch-based: when RND(0) is called, the clock time since the computer was powered on is used in generating a new seed, meaning that if RND(0) replaces RND(1), each run 10 PRINT at a different second should generate a different output. After a single call to RND(0), subsequent calls to RND(1) will continue generating numbers in that new sequence.

Revision as of 11:26, 18 July 2011

View this revision of Randomness.

Personal tools