Randomness

From Maze

(Difference between revisions)
Jump to: navigation, search
(→The SID: Sound as a second stochastic source)
(→The SID: Sound as a second stochastic source)
Line 169:Line 169:
By setting oscillator 3 on the SID chip to generate noise, then reading a noise output value in from register 27, a C64 BASIC or assembly program can draw on a second source of random numbers that changed constantly at the currently set speed of the oscillator. Because the SID is a mixed-signal integrated circuit (with digital control ports and analog output ports), a common misconception about the SID has been that it is a source of "true" or "high-quality" hardware-based random number generation, producing analog noise that was somehow the result of an analog process -- perhaps thermal noise, shot noise, or some other physical measurement of quantum indeterminacy.
By setting oscillator 3 on the SID chip to generate noise, then reading a noise output value in from register 27, a C64 BASIC or assembly program can draw on a second source of random numbers that changed constantly at the currently set speed of the oscillator. Because the SID is a mixed-signal integrated circuit (with digital control ports and analog output ports), a common misconception about the SID has been that it is a source of "true" or "high-quality" hardware-based random number generation, producing analog noise that was somehow the result of an analog process -- perhaps thermal noise, shot noise, or some other physical measurement of quantum indeterminacy.
−
However, this is not the case. SID noise is digitally generated by a 23-bit linear feedback shift register (LFSR), another common form of deterministically generating pseudorandom numbers.
+
However, this is not the case. SID noise is digitally generated by a 23-bit linear feedback shift register (LFSR), another common form of deterministically generating pseudorandom numbers. In an LFSR, a few selected bits are used to calculate one additional bit, then all old bits are shifted over one, with the new bit added to the top, and the process is repeated. In the SID, the result is something like a continuously running RND(1).
 +
 +
[NOTE: This really ends with a whimper right now. I'm not sure how to end on the SID and then bring this chapter home -- perhaps the SID section should be an aside in the previous section, and not its own.]
----
----
−
----
+
<blockquote>[SUGGESTION: INTRODUCE THE FOLLOWING PROGRAMS BY DESCRIBING THE FUNCTION OF THE PEEK AND POKE AND WALKING READER THROUGH THE WAY THIS PROGRAMS CALL UPON THE SID]
−
[SUGGESTION: INTRODUCE THE FOLLOWING PROGRAMS BY DESCRIBING THE FUNCTION OF THE PEEK AND POKE AND WALKING READER THROUGH THE WAY THIS PROGRAMS CALL UPON THE SID]
+
[Jeremy: On review, I'm not totally convinced of the value of working through complex textbook examples of using the SID with BASIC peek-poke (as below) -- particularly because use of the SID is already quite removed from the RND(1) method of how 10 Print does randomness, with RND(-x) and RND(0) / RND(TI) being closer. If we haven't introduced peek and poke already, it seems like a stretch to do it here. I'm more inclined to tersely summarize this material as one or two examples maximum, perhaps with direct reference to "Random Numbers In Machine Language For Commodore 64" (Neil Boyle)
−
 
−
[Jeremy: On review, I'm not totally convinced of the value of working through complex textbook examples of using the SID with BASIC peek-poke (as below) -- particularly because use of the SID is already quite removed from the RND(1) method of how 10 Print does randomness, with RND(-x) and RND(0) / RND(TI) being closer. I'm more inclined to tersely summarize this material as one or two examples maximum, perhaps with direct reference to "Random Numbers In Machine Language For Commodore 64" (Neil Boyle)
 
http://www.atarimagazines.com/compute/issue72/random_numbers.php
http://www.atarimagazines.com/compute/issue72/random_numbers.php
 +
...also, I believe that some of the below is pseudocode, unless 'osc3read' is something that just doesn't work on the Power64 emulator.
]
]
−
 
<pre>
<pre>
5 s=54272:poke s+15,100:pokes+18,128
5 s=54272:poke s+15,100:pokes+18,128
Line 211:Line 211:
</pre>
</pre>
−
----
+
</blockquote>
----
----

Revision as of 02:10, 12 July 2011

View this revision of Randomness.

Personal tools