There is a potential confusion in the term randomSeed.  We might be using it 
two ways.

There is the randomSeed property, the state of the random number generator.  

And there is the argument to the random function.


And...
Shouldn't the 'get fld 1' be inside the loop?  (Or initialized the same way 
each time.) You are using the previous sorted 'it' each time.  Perhaps that is 
what is doing the scrambling.

This is my test:

on mouseUp
   set the cursor to watch
   put 0 into a1
   put 0 into a2
   put 0 into a3
   put "a" & lf & "b" & lf & "c" into x
   repeat 1000000 times
      put x into myVar
      --sort lines of myVar by random(the number of lines of myVar)
      sort lines of myVar by random(999999)
      if line 1 of myVar is "a" then add 1 to a1
      if line 2 of myVar is "a" then add 1 to a2
      if line 3 of myVar is "a" then add 1 to a3
   end repeat
   put a1 && a2 && a3 into field 1
end mouseUp

I got different results depending on which line is commented out.

Dar


On May 22, 2013, at 2:46 PM, dunb...@aol.com wrote:

> Sorting by a randomSeed greater than the number of elements of a sample does 
> not help.
> 
> 
> With the following in a fld 1:   aaa,bbb,ccc
> 
> 
> and this in a button:
> 
> on mouseUp
>   get fld 1
>   repeat  1000
>      sort items of it by random(3)
>      put it & return after lowSeed
>   end repeat
> 
>   repeat  1000
>      sort items of it  by random(3333)
>      put it & return after highSeed
>   end repeat
> 
>   repeat with y = 1 to the number of lines of lowSeed
>      add 1 to lowSeedCounter[line y of lowSeed]
>   end repeat
> 
>   repeat with y = 1 to the number of lines of highSeed
>      add 1 to highSeedCounter[line y of highSeed]
>   end repeat
> 
> end mouseUp
> 
> 
> The distribution of the two groups is about the same. 
> 
> 
> Craig Newman
> 
> 
> 
> 
> -----Original Message-----
> From: Dar Scott <d...@swcp.com>
> To: How to use LiveCode <use-livecode@lists.runrev.com>
> Sent: Wed, May 22, 2013 3:59 pm
> Subject: Re: randomly order a list
> 
> 
> Try replacing 'the number of lines of myVar' with some huge number you think 
> is 
> allowed for random(), say 999999.
> 
> With small numbers you are likely to get the same number for different lines 
> and 
> perhaps sort does not change order in that case. 
> 
> Dar
> 
> 
> On May 22, 2013, at 11:59 AM, Chris Sheffield wrote:
...
>> 
>>      sort lines of myVar by random(the number of lines of myVar)
>> 
...
>> 
>> --
>> Chris Sheffield
>> Read Naturally, Inc.
>> www.readnaturally.com
> 

_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to