Sorting question
Peter Brigham MD
pmbrig at gmail.com
Thu Feb 11 10:22:43 CST 2010
Brian Yennie gave the explanation. When you use random(3) as a sort
key you have a high chance (in fact I think it's 50%) that two of the
items will be assigned the same sort key, and thus their relative
position will be preserved, giving a decidedly non-random sort. If you
sort by random(1000000) or some suitably high number the chances of
getting the same sortkey in your three iterations is miniscule.
-- Peter
Peter M. Brigham
pmbrig at gmail.com
http://home.comcast.net/~pmbrig
On Feb 11, 2010, at 10:20 AM, DunbarX at aol.com wrote:
> Thanks for the responses, but I think there is an issue here.
>
> I figured a sort value was assigned to each item, and certainly a
> larger
> value of n in random(n) gives, what, more room to move?
>
> I would expect 1000 iterations of random(3) to give an even spread
> of 1's,
> 2's and 3's. It does, of course.
>
> Howwever, randomizing, through 1000 iterations, my three items with
> random(3) yields a list heavily weighted in favor of item 1. It
> appears far more
> often, repeatably, than it ought to. Why item 1? With random(100) the
> dispersion is as expected. The value of n has to be about 15 or more
> to yield what
> looks like a reasonable output, at least with three or four items,
> the only
> options I tested.
>
> I don't get why.
>
> Craig Newman
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
More information about the use-livecode
mailing list