in reply to Randomize List of items
I think the randomization is complete... can anybody see a reason why it wouldn't be?my @newList = sort {rand > .5} @oldList;
|
---|
Replies are listed 'Best First'. | |
---|---|
RE: RE: Randomize List of items
by Russ (Deacon) on May 19, 2000 at 03:48 UTC | |
78945612103
80, 79, 75, 67, 65, 57, 72, 62, 71, 61, 52, 95, 68, 87, 83, 82, 59, 78, 58, 77, 100, 64, 88, 97, 99, 74, 96, 1, 94, 3, 4, 98, 6, 8, 15, 17, 20, 22, 24, 26, 30, 31, 33, 34, 38, 39, 40, 44, 49, 50, 51, 53, 54, 55, 56, 60, 63, 66, 69, 70, 73, 76, 81, 84, 85, 86, 89, 90, 91, 92, 93, 35, 36, 10, 29, 48, 7, 32, 28, 42, 25, 47, 16, 41, 14, 46, 13, 45, 12, 11, 43, 9, 5, 21, 23, 37, 2, 18, 27, 19 I don't have the mathematical background to correctly analyze this, but based on what I know about quicksort, this doesn't surprise me a lot. It feels strange, anyway. This kind of stuff makes me wish I'd taken more math, but my intuition tells me Bruce Schneier would not approve... :-)
| [reply] |
RE: RE: Randomize List of items
by chromatic (Archbishop) on May 19, 2000 at 03:41 UTC | |
I see a lot of clumping. | [reply] [d/l] |
by johannz (Hermit) on May 19, 2000 at 03:58 UTC | |
Here is the code I used to test these. I create a list of 100 items, and randomize that list and record the resulting positions 100,000 times. The average positions for each number should hover around the mid-point of the list. Both of these do. Here's the code( yes, it's a quick hack!) If there is a problem with my methodology for testing this, I would appreciate it being pointed out. | [reply] [d/l] |
by Russ (Deacon) on May 19, 2000 at 04:17 UTC | |
:-) Okay, after 14 minutes (!), I saw similar results. The problem, as I see it, is not the distribution around the median, but the predictability of successive elements.
Any given number may have an equal chance of being at any
location in the result array. However, there seems to be
a very large probability (certainly greater than random)
that for a given element, the element which starts next to
this one will end up very close to wherever this element
ends up. Obviously, neither of the two solutions (the original post and this one) is suitable for strong cryptography (no solution which only uses a pseudo-random number generator will be). Russ | [reply] |
RE: RE: Randomize List of items
by turnstep (Parson) on May 19, 2000 at 16:21 UTC | |
Looks random to me. Check this out:
Results:
| [reply] [d/l] [select] |