Bill Frantz (frantz@netcom.com)
Thu, 29 Oct 1998 01:04:55 -0800
At 3:32 PM -0800 10/28/98, Anonymous wrote:
>In the following snippet of pseudo-code, what should the value of
>SWAP_TIMES be to make the array A[] random, assuming
>that getrand() returned a truly random integer between
>0 and 255
>
>A[256];
>
>for(i=0;i<SWAP_TIMES;i++){
> x=getrand();
> y=getrand();
> swap(A[x],A[y]);
>}
My experiments with the Arc4 key schedule, which is closer to:
for (try=0; try<TIMES; try++) {
for (i=0; i<A.length; i++) {
x = getrand()
swap(A[i], A[x]);
}
}
suggest that TIMES should be 2. That would make me think that SWAP_TIMES
should be 512. However that thought ignores the feature of the Arc4 key
schedule which ensures that each entry is visited at least once. Picking x
and y both randomly does not have this assurance.
I expect to have a more detailed post on the Arc4 schedule as applied to
the problem of continuously seeded pseudorandom number generation in a few
days.
-------------------------------------------------------------------------
Bill Frantz | Macintosh: Didn't do every-| Periwinkle -- Consulting
(408)356-8506 | thing right, but did know | 16345 Englewood Ave.
frantz@netcom.com | the century would end. | Los Gatos, CA 95032, USA
The following archive was created by hippie-mail 7.98617-22 on Sat Apr 10 1999 - 01:15:23