Randomizing trials question #790
-
Hi all! So I asked a question a few weeks ago on how to get only certain critical trials in my experiment to randomize. Since then I’ve had to make some additional changes to my experiment, and now I need it so that only certain sets of critical trials will randomize with one another. Namely, I need trials [2, 7, 12, 18] to only randomize with one another, and trials [4, 10, 15, 20] to only randomize with one another (right now the code randomizes both sets of these trials together). The rest of the trials in my code will always be in the same order in the experiment. Any help would be greatly appreciated! Here is the code that I have now: var test_procedure = {
timeline: [likert_trial, multi_select, text_page],
sample: {
type: "custom",
fn: function() {
var trials_to_randomize = [2,4,7,10,12,15,18,20];
var random_order = jsPsych.randomization.shuffle(trials_to_randomize);
return [
0,
1,
random_order[0],
3,
random_order[1],
5,
6,
random_order[2],
8,
9,
random_order[3],
11,
random_order[4],
13,
14,
random_order[5],
16,
17,
random_order[6],
19,
random_order[7]
];
} |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 4 replies
-
You might be looking for something like this var random_order_1 = jsPsych.randomization.shuffle([2, 7, 12, 18]);
var random_order_2 = jsPsych.randomization.shuffle([4, 10, 15, 20]);
return [
0,
1,
random_order_1[0],
3,
random_order_2[0],
5,
6,
random_order_1[1],
8,
9,
random_order_2[1],
11,
random_order_1[2],
13,
14,
random_order_2[2],
16,
17,
random_order_1[3],
19,
random_order_2[3]
]; |
Beta Was this translation helpful? Give feedback.
-
Thanks for the help! I tried it out but it seems that all the trials are still randomizing together and not as separate sets. I tried removing the first 'var random order', and then tried removing 'var trials_to_randomize' from the code to if that would work but then the experiment wouldn't run at all. |
Beta Was this translation helpful? Give feedback.
-
When I adjust the code like this, then the entire experiment stops working (nothing is displayed when I open the file). Any idea why this could be? |
Beta Was this translation helpful? Give feedback.
-
Hi! So I tried that got the following messages when I tried to run the experiment: |
Beta Was this translation helpful? Give feedback.
-
Wow, totally my bad! That's what I get for coding half asleep lol It's working perfect now! Thanks again for all your help!! |
Beta Was this translation helpful? Give feedback.
Thanks for the help!
I tried it out but it seems that all the trials are still randomizing together and not as separate sets. I tried removing the first 'var random order', and then tried removing 'var trials_to_randomize' from the code to if that would work but then the experiment wouldn't run at all.