Jump to content

Talk:Subtractive generator: Difference between revisions

(task desc wrong)
Line 41:
for (1 .. 10) { say scalar(@state), ": ", subrand(); }</lang> gave me different answers. --[[User:Ledrug|Ledrug]] 17:32, 2 August 2011 (UTC)
:EDIT I looked at Bentley's C code, and the task description is incorrect. After step 4, the sequence r0 ... r54 needs to be reversed. Bentley's code performs step 3 forward, but generates rand numbers by iterating the r array backward. --[[User:Ledrug|Ledrug]] 17:51, 2 August 2011 (UTC)
::No, I used an arbitrary seed. The text on the main page said "For example, if the seed is 292929" so I presumed that that was not a part of the task. Using 292929 as the seed, and j=24, I get 28 unique values in S220 through S274. If I instead use j=21, I get 48 unique values. Reversing r0..r54 before indexing them does not change this (though it does change the specific non-unique values that show up -- without reversal they are 585858 585860 878785 998828285 999121210 999121217 999414144 but with reversal they are 292925 292931 585858 1171714 998242429 999121212 999999998). --[[User:Rdm|Rdm]] 19:06, 2 August 2011 (UTC)
6,962

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.