vendredi 13 octobre 2023

Shuffling a vector in Matlab with constraints (a specific number of 2-back repetitions)

I'm setting up a Matlab program where people will see a series of 15 words (e.g., 'dog', 'cat', 'fish', 'goat', etc.). One word will be presented per trial, and the full series of words will repeat 40 times (total = 600 trials; 40 unique appearances of each of the 15 words).

I want to arrange the trial order such that it's pseudorandom: on 50% of trials (starting from trial 3 onwards), the word should be the same as the word that was presented two trials previously. For example, a valid trial order (on a much smaller scale) would be:

  • Trial 1: dog (too early to be a 2-back repeat)
  • Trial 2: cat (too early to be a 2-back repeat)
  • Trial 3: dog (2-back repeat)
  • Trial 4: fish (not a 2-back repeat)
  • Trial 5: goat (not a 2-back repeat)
  • Trial 6: fish (2-back repeat)
  • Trial 7: goat (2-back repeat)
  • Trial 8: cat (not a 2-back repeat)

The above is valid because each of the 4 words appears equally often (here, twice each), with an equal number of 2-back repeats and non-repeats from trial 3 onwards.

I would also be ok with the number of 2-back repeats not equalling 50% exactly, but it should be close (e.g., somewhere between 40% and 60%). But, I'm not sure how to maintain this constraint while still ensuring that each of the 15 words repeats an equal number of times (40 times) across the full set of trials (600 trials).

Any help is greatly appreciated! Thanks in advance.

I've tried the brute force approach of reshuffling the full set of trials until the constraint is met by chance, but that takes much too long to process.




Aucun commentaire:

Enregistrer un commentaire