Shuffle list with restriction

Preparing a new psychophysical experiment, I have 48 original stimuli displayed 4 times (4 conditions), which led to 192 trials. Trying to randomize the order of presentation during the experiment, I need to maximize the distance between the 4 displays of the same original stimuli.

Please consider:

Table[{j, i}, {j, Range[48]}, {i, Range[4]}]

Where j is the initial number of stimuli and i condition

Output Sample:

 {{1, 1}, {1, 2}, {1, 3}, {1, 4}, 
  {2, 1}, {2, 2}, {2, 3}, {2, 4},   
  ...
  {47, 1}, {47, 2}, {47, 3},{47, 4}, 
  {48, 1}, {48, 2}, {48, 3}, {48, 4}}

How could I shuffle the order of presentation of these 192 points, maximizing the distance between identical elements with respect to j, the number of the initial stimulus?

+5
source share
4 answers

. 4 48 ( ). 48 .

192 , , 38,6 1 144 :

t = Flatten[Table[i, {4}, {i, 48}]]; 

{Mean[#], StandardDeviation[#]} &@  
Table[
  rs = RandomSample[t, 192];
    Mean[Mean[Differences[Flatten[Position[rs, #]]]] & /@ Range[48]] // 
   N, {10000}
]

(* ==> {38.60370417, 1.397151004} *)

-. 48 2 24 (1-24 [ I] 25-48 [ II]). (p) II: p (I) p (II) p (I) p (II) p (I) p (II) p (I) p (II).

:

{Mean[#], StandardDeviation[#]} &@  
Table[
  rs = 
    Join[RandomSample[Range[24]], RandomSample[Range[25, 48]], 
         RandomSample[Range[24]], RandomSample[Range[25, 48]],
         RandomSample[Range[24]], RandomSample[Range[25, 48]], 
         RandomSample[Range[24]], RandomSample[Range[25, 48]]
    ];
  Mean[Mean[Differences[Flatten[Position[rs, #]]]] & /@ Range[48]] //N, {10000}]

(* ==> {48., 0.} *)

, , 48 ( 24, - 47). 0. , .


1
, 1-24 25-48. , . .


2
, :

:

m = MapThread[
       List, 
       {
         Table[Range[48], {4}], 
         Table[RandomSample[{1, 2, 3, 4}], {48}]\[Transpose]
       }, 2
    ]

24, :

Flatten[RandomSample /@ Partition[Flatten[m, 1], 24], 1]

( 1), :

initialArrangement = RandomSample[Range[48]]; 
m = 
 MapThread[
    List, 
    {
       Table[initialArrangement, {4}], 
       Table[RandomSample[{1, 2, 3, 4}], {48}]\[Transpose]
    }, 2
 ]

, (RandomSample[Range[48]]) Table!


Mr.Wizard , , ; -)

m~Set~MapThread[List, (Range[48]~Table~{4}~
    List~((RandomSample[{1, 2, 3, 4}]~Table~ {48})\[Transpose])), 2]

:

(RandomSample /@ m~Flatten~1~Partition~24)~Flatten~1

, :

initialArrangement~Set~RandomSample[Range[48]]; 
m~Set~MapThread[List, (initialArrangement~Table~{4}~
    List~((RandomSample[{1, 2, 3, 4}]~Table~ {48})\[Transpose])), 2]

BTW , , , .

+9

:

a = RandomSample@Range@48;
Flatten[Array[Partition[Riffle[a, #1], 2] &, 4], 1]
+3

, :

RandomSample[Flatten[Table[{j, i}, {j, Range[48]}, {i, Range[4]}], 1]]
+2

.

: ​​

Table[{j, i}, {j, Range[48]}, {i, Range[4]}]

:

Table[{j, i}, {j, 48}, {i, 4}]

Array:

List ~Array~ {48, 4}

, , :

Tuples@Range@{48, 4}
+2

All Articles