Random number generation is too important to be left to chance. — Ivars Peterson
This page discusses some details on what the in random order option for tables does. It's not intended to be a full discussion of randomness, pseudo-randomness or the interaction of random selections. Nor does it explain all the details of the inner workings of PsyScript when handling tables.
Consider the following table:
If PsyScript used random numbers in the normal way to select items from this table it would pick a number from one to five each time it needed a row from the table. Running a script which selected five animals would be very likely (p = 601/625 = .9616) to pick at least one row more than once. This means that if you used random numbers to present five stimuli to your participant, they'd probably see at least one of them twice and miss seeing one entirely. This is not what a psychologist wants so PsyScript doesn't work that way.
PsyScript does not roll a die, it shuffles cards. When faced with a table marked with 'in random order' it shuffles the order of the table, then picks each card. When it runs out of table rows it shuffles the rows again. This means that you can use a ten-row table in an experiment which shows five stimuli each to two participants, and each row will be used exactly once.
This policy is applied even under two difficult circumstances:
In each case, PsyScript retains its notes about how each table has been used so far, making sure that an 'equal use' policy is applied over multiple uses of the table within one script, and over uses of the same script for different participants within the same session.
This method does not prevent a stimulus from appearing twice in a row, however. Consider a case where the above table was used in an experiment which showed two stimuli to each participant. The rows might be selected in this order:
participant 1 sees horse.jpeg mouse.jpeg participant 2 sees duck.jpeg badger.jpeg participant 3 sees fox.jpeg SCRIPT RUNS OUT OF STIMULI HERE
The third participant sees
fox.jpeg
as their first stimulus. Once the script has used that row it runs out of entries in the table and has to shuffle the order of the table again. When it does that, there's a chance (p = 0.2) that fox.jpeg
will turn out to be the first entry of the new random order: participant 3 would see the same stimulus twice. This is probably not what the experimenter wants.
To avoid this, when presenting an experiment which requires 'pick any n of m' use of a table, make sure that m is a multiple of n. In other words, that selecting the rows for one participant will always fit neatly into one shuffling of the rows of the table.
In the example case where each participants sees 2 entries, this means that 4 or 6 entries would be a good length for the table, but 5 would be a poor length for the table.
See also