PennController for IBEX › Forums › Support › Is it possible to shuffle trials according to a % of times?
- This topic has 4 replies, 2 voices, and was last updated 2 years, 4 months ago by
Larissa_Cury.
-
AuthorPosts
-
April 28, 2022 at 6:36 pm #8127
Larissa_Cury
ParticipantHello!
I’m wondering if it’s possible to use shuffle() to shuffle 4 trials. I won’t share a link because I still haven’t started the experiment, but the ideia is this:
shuffle 4 trials ()
A (70%)
B (10%)
C (10%)
D (10%)I need them in random order (shuffle), but each of them has different proportions of apperance (in parenthesis)…Is is possible to shuffle them accordingly?
Best,
April 28, 2022 at 6:52 pm #8128Jeremy
KeymasterHi,
Using
shuffle
in the sequence will “specif[y] that items matching the given predicates should be shuffled together in such a way that items matching each predicate are evenly spaced. The original relative ordering between items of the same type is preserved.”For example, the following will get as close as possible to separate two B, two C and two D trials with 9 other trials in between, but A trials won’t be separated by more than ~2 trials overall, because of the proportions of trials
Sequence(shuffle("A","B","C","D")) for (let i = 0; i<70; i++) newTrial("A", newButton("A"+i).print().wait()) for (let i = 0; i<10; i++) newTrial("B", newButton("B"+i).print().wait()) for (let i = 0; i<10; i++) newTrial("C", newButton("C"+i).print().wait()) for (let i = 0; i<10; i++) newTrial("D", newButton("D"+i).print().wait())
That's if you have 4 different labels, and actually create 70/10/10/10 trials. But if you only create a total 4 trials, but want to repeat them following a 70/10/10/10 distribution, you could do that:
Sequence(shuffle( ...[...new Array(70)].map(v=>"A"), ...[...new Array(10)].map(v=>"B"), ...[...new Array(10)].map(v=>"C"), ...[...new Array(10)].map(v=>"D"), )) newTrial("A", newButton("A").print().wait()) newTrial("B", newButton("B").print().wait()) newTrial("C", newButton("C").print().wait()) newTrial("D", newButton("D").print().wait())
Does that answer your question?
Jeremy
April 29, 2022 at 10:58 am #8130Larissa_Cury
ParticipantDear Jeremy, thank you as always! Yes, I’m going to create 4 different trials with 4 different lables, I’m wondering why solution number two wouldn’t work with different lables?
Best,
April 29, 2022 at 4:36 pm #8132Jeremy
KeymasterDear Larissa,
Both solutions use the same set of four labels, namely
"A"
,"B"
,"C"
and"D"
The first piece of code creates a total of 100 trials: 70 A trials, 10 B trials, 10 C trials and 10 D trials. The text of the button in the first A trial is “A0”, in the second A trial it is “A1”, etc. and similarly for the “B” trials (“B0”, “B1”, etc.), the “C” trials and the “D” trials
The second piece of code creates a total of 4 trials: 1 A trial (button text: “A”), 1 B trial (button text: “B”), 1 C trial (button text: “C”) and 1 D trial (button text: “D”). However, the
Sequence
repeats the A trial 70 times, the B trial 10 times, the C trial 10 times and the D trial 10 timesBoth pieces of code use
shuffle
inSequence
, resulting in a balanced distribution in both casesJeremy
April 29, 2022 at 5:31 pm #8135Larissa_Cury
ParticipantOhhhhh, got it! Thank you very much, Jeremy!! 😄
-
AuthorPosts
- You must be logged in to reply to this topic.