Choosing subet of items to present

PennController for IBEX Forums Support Choosing subet of items to present

This topic contains 2 replies, has 2 voices, and was last updated by Avatar mg5171 1 week, 3 days ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #4890

    I’m wondering if there’s a way to choose a random subset of items to present, and to mix in fillers and stim items.

    1. Random subset of items: I’d like to present all of the items labeled ‘stim’, but a random subset of 50 labeled ‘filler’. I currently have two blocks, one of which presents all of the ‘stim’ items, and another which presents all of the ‘filler’ items, like this:

        PennController.defaultTable.filter("type", "stim"), //choose only stimuli items
        variable => 

    I have an analogous one for ‘filler’ items–but I want to tell it to choose a random subset of e.g. 50, instead of presenting all of them.

    2. If I can manage that, then I have 2 blocks, one with stim and one with fillers. I know about the randomize and shuffle commands that go with Sequence() at the beginning. Is there some combination of those I can use to randomize both stim and fillers, and then present them all in a random order?


    • This topic was modified 2 weeks, 1 day ago by Avatar mg5171.

    Hi Maddie

    1. I can see a couple ways to do this, but you’ll need some plain javascript anyway. Here’s a suggestion, assuming you have an Item column in your table that goes from 0 to, say, 100 for your filler items:

    numberRows = 100;
    numberDraws = 50;
    randomIDs = [ Array(numberRows)].map((v,i)=>i).sort(v=>Math.random()>0.5).splice(0,numberDraws);
    Template( defaultTable.filter( r => r.type=="filler" && randomIDs.indexOf(Number(r.Item))>-1 ),
      variable => newTrial(
        // ...

    2. I think what you are looking for is anyOf, you can use it like this: Sequence( "intro" , randomize(anyOf("experiment","filler")) )


    Thanks so much Jeremy!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.