Pick combined with randomizeNoMoreThan

PennController for IBEX Forums Support Pick combined with randomizeNoMoreThan

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #7675
    aliona
    Participant

    Dear Jeremy,

    I have been using the Pick function to have my items presented in 3 blocks separated by 2 breaks. The critical and the filler items are well randomized, but sometimes they appear in long sequences of same-answer trials for the post-sentence question (e.g., 4-5 with a ‘yes’-answer followed by 4-5 with a ‘no’-answer).

    Is there a way I could combine the Pick function and maybe randomizeNoMoreThan function to specify that I don’t want to have, say, more than 3 same-answer trials regardless of whether they’re critical or filler (which is specified in a column called “match” with “yes” and “no” values in it)?

    Thanks in advance for your help!
    Aliona

    P.S: here are my Pick function and sequence just in case.

    
    function Pick(set,n) {
        assert(set instanceof Object, "First argument of pick cannot be a plain string" );
        n = Number(n);
        if (isNaN(n) || n<0)
            n = 0;
        this.args = [set];
        this.runSet = null;
        set.remainingSet = null;
        this.run = arrays => {
            if (this.runSet!==null) return this.runSet;
            const newArray = [];
            if (set.remainingSet===null) {
            if (set.runSet instanceof Array) set.remainingSet = [...set.runSet];
            else set.remainingSet = arrays[0];
        }
            for (let i = 0; i < n && set.remainingSet.length; i++)
                newArray.push( set.remainingSet.shift() );
        this.runSet = [...newArray];
        return newArray;
    }
    }
        function pick(set, n) { return new Pick(set,n); }
            
            critical = randomize("critical")
            fillers = randomize("filler");
    PennController.Sequence("demographics","etc",
                            rshuffle(pick(critical,8),pick(fillers,11)),"break",
                            rshuffle(pick(critical,8),pick(fillers,11)),"break",
                            rshuffle(pick(critical,8),pick(fillers,11)),
                            "etc");
    • This topic was modified 2 years, 4 months ago by aliona.
    #7680
    Jeremy
    Keymaster

    Hi Aliona,

    The Sequence command and the related functions only care about the trials’ labels: if you yes-answer and no-answer trials share the same labels, you won’t be able to control their distribution. I suggest you include the yes/no bit of information in the trials’ labels, eg "critical-yes"/"critical-no" and "filler-yes"/"filler-no"

    The pick function will pick the N next trials from a set: when you do pick(critical,8) and critical was set to randomize("critical"), it will pick 8 trials from a randomized set of all the trials labeled “critical”. Then you pass that to rshuffle, so those 8 trials will be interspersed with trials labeled “filler” in the order in which they were picked from critical

    You could do that, in which case two critical-yes trials would always be separated by a critical-no, a filler-yes and a filler-no trial:

    criticalyes = randomize("critical-yes")
    criticalno = randomize("critical-no")
    fillersyes = randomize("filler-yes")
    fillersno = randomize("filler-no")
    
    Sequence("demographics","etc",
             rshuffle(pick(criticalyes,4),pick(fillersyes,6),pick(criticalno,4),pick(fillersno,5)),"break",
             rshuffle(pick(criticalyes,4),pick(fillersyes,5),pick(criticalno,4),pick(fillersno,6)),"break",
             rshuffle(pick(criticalyes,4),pick(fillersyes,6),pick(criticalno,4),pick(fillersno,5)),
             "etc")

    Don’t forget to add -yes/-no to your trials’ labels, and make sure the 5/6 match the number of different types of trials you have (I went with 17 filler-yes trials and 16 filler-no trials, for a total of 33 filler trials)

    Jeremy

    #7685
    aliona
    Participant

    Hi Jeremy,

    it worked out perfectly! Thanks for the help.

    Aliona

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