How to ensure different distractor images are shown an equal number of times? #777
-
Hi everyone, function shuffleArray(myArray) {
var randNum, tempStore, j;
for (j = myArray.length; j; j--) {
randNum = Math.floor(Math.random() * j);
tempStore = myArray[j - 1];
myArray[j - 1] = myArray[randNum];
myArray[randNum] = tempStore;
}
};
function sampleArray(myArray) {
return myArray[Math.floor(Math.random() * myArray.length)];
}; |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 11 replies
-
How are these functions used in the current script? |
Beta Was this translation helpful? Give feedback.
-
So the participant sees a stream of images. When they see a filler, they don't respond. When they see a distractor, they don't respond, but when they see a target, they respond with either left or right, correct? The actual position of the filler items doesn't not matter, nor do the targets, and both filler items and targets can be repeated. However, you have a specific set of distractors that you'd like to display in a controlled manner from 4 categories. They should not repeat (no distractor after distractor) and should be inserted into the image stream with even numbers of them from 4 categories. Am I understanding this right? The sample array function just picks a random image from the distractors list and ignores the category of the distractor. Is that the problem? |
Beta Was this translation helpful? Give feedback.
How are these functions used in the current script?