Is it possible to shuffle trials according to a % of times?

PennController for IBEX Forums Support Is it possible to shuffle trials according to a % of times?

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #8127


    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?




    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

    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:

        ...[ Array(70)].map(v=>"A"),
        ...[ Array(10)].map(v=>"B"),
        ...[ Array(10)].map(v=>"C"),
        ...[ 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?



    Dear 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?



    Dear 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 times

    Both pieces of code use shuffle in Sequence, resulting in a balanced distribution in both cases



    Ohhhhh, got it! Thank you very much, Jeremy!! 😄

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.