Randomization with no more than three items of same category in a row

PennController for IBEX Forums Support Randomization with no more than three items of same category in a row

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #8239
    BenG
    Participant

    Hi Jeremy,

    I am setting up an experiment in which participants are presented with images and are required to name them by typing a response into a response box.

    The participants are presented with these images in a random order. However, as these images come from 6 categories (i.e., animals, fruits, etc.), I would like to ensure that no more than three items from the same category can be presented in a row. Currently, I am randomizing the items as follows (the items are randomized twice – this may not be needed):

    critical = randomize("experimental_items");
    
    Sequence("WelcomeConsent",
        "counter",
        "demographics",   
        "instructions1",
        "exercise",
        "startofexp",
        rshuffle(pick(critical, 61)), "break",
        rshuffle(pick(critical, 61)), "break",
        rshuffle(pick(critical, 61)),
        SendResults(),
        "Bye");

    Is there a way to achieve this?

    Thank you in advance for your help!

    link to experiment: https://farm.pcibex.net/r/oRsnBC/

    #8241
    Jeremy
    Keymaster

    Hi,

    You need to include the category information in the trials’ labels, otherwise the various sequence functions will have no way of knowing which trial is from which category, and therefore you’ll have no hope of constraining their distribution

    I wrote a function called randomizeNoMoreThan that does what you want. Once you’ve added a .js file defining the function to your project’s Modules folder, you can proceed to the following modifications:

    • replace newTrial("experimental_items" with newTrial("experimental_items_"+row.Kategorie
    • replace critical = randomize("experimental_items"); with critical = randomizeNoMoreThan(startsWith("experimental_items"), 3);
    • replace all three occurrences of rshuffle(pick(critical, 61)) with pick(critical, 61)

    Since pick selects consecutive trials from a set (ie. the next 61 trials it picks follow the previous 61 trials it picked in the set stored in the critical variable) and since the set stored in critical has been randomized using randomizedNoMoreThan, you should get the desired behavior

    Jeremy

    #9730
    dimitra_94
    Participant

    Hi Jeremy,

    I have a very similar question to the one posed here, but I cannot seem to make it work unfortunately. So I am creating a rating study with 22 photos and 10 questions. Each photo appears ten times with each question so I have 220 items in total. I also have 4 practice items that appear with five of the questions so another 20 items in the beginning. I am using the pick function in order to add breaks and attention checks in between, as well as randomise the items, but some items come up two or three times in a row, something that I want to avoid – I do not wish to have any duplicates.

    I have tried replicating the code you provided above (+ uploaded the .js file to js_includes) but with no success so far.

    My sequence looks like this:

    practice = randomizeNoMoreThan(startsWith("practice_trials"), 1);
    critical = randomizeNoMoreThan(startsWith("experimental_trials"), 1);
    
    PennController.Sequence("welcome",
                            "demographics",
                            "instruction",
                            "exampleinstruction",
                            pick(practice, 20),
                            "end_practice",
                            pick(critical, 55),
                            "attentionCheck1",
                            pick(critical, 55),
                            "break",
                            pick(critical, 55),
                            "attentionCheck2",
                            pick(critical, 55),
                           "send", "final")

    and then within my trials I have this format (VP is the column with the coding of the photos that I do not want to see more than once in a row):

    PennController.Template(
        PennController.GetTable("List_1.csv")
            .filter("trial_type", "practice")
                             ,
                             variable => ["practice_trials_row.VP"
    
    
     PennController.Template(
        PennController.GetTable("List_1.csv")
            .filter("trial_type", "experimental")
                             ,
                             variable => ["experimental_trials_row.VP"

    Is there a way to fix this? (Link to the experiment: https://korpling.german.hu-berlin.de/ibexexps/tsiapoud/Fotodatenbank_Pretest_List_1/experiment.html)

    Thanks in advance!
    Dimitra

    • This reply was modified 6 months, 1 week ago by dimitra_94.
    • This reply was modified 6 months, 1 week ago by dimitra_94.
    #9745
    Jeremy
    Keymaster

    Hi Dimitra,

    Assuming you are willing to merge together the four blocks of experimental trials (otherwise the items sharing the same picture would never appear in a row to start with, since you seem to use each picture only once per block) you can make it work as in this project (I have updated some commands to match the modern PennController syntax — you also seemed to use the same code for all your trials, practice and experimental, so I use a single Template command)

    Jeremy

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