Randomizer

PennController for IBEX Forums Support Randomizer

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #7823
    Mate208
    Participant

    Hi Jeremy,
    I have a question regarding the use of randomizers in the command Sequence.
    Is there a way actually randomize two randomizers?

    Down here is how I set my sequence. The first randomizer is something I sent you by mail about the way to randomly, from a CSV file, take 36 sentences of a long list of items.
    Sequence("consent", practice, randomize(startsWith("GreetingsTrial")), randomize("other"), "send", "final")

    Then, the second randomizer contains a bunch of sentences that I need to randomly show to each participant, but this time, all the sentences from that file must be shown (which was the the case with the other randomizer).

    Is there any way to ”mix” those randomizers together, which would make a new randomizer of the randomized sentences by keeping their random order properties?

    Marc

    #7826
    Jeremy
    Keymaster

    Hi Marc,

    I think mixing in other trials inside the “GreetingsTrial” is incompatible with the modifyRunningOrder function we discussed in our email exchange. So you would be better off using a custom shuffle sequence function instead of using modifyRunningOrder:

    function KeepOneInGroupAfter(x,sep='_') {
        this.args = [x];
        this.run = function(arrays) {
            const ret = []
            const sources = {};
            arrays[0].forEach( r=> {
                let type = r[0].type.split(sep);
                type.shift();
                type = type.join(sep);
                sources[type] = [...(sources[type]||[]),r];
            });
            for (let k in sources){
                fisherYates(sources[k])  // Randomize trials in the group
                ret.push(sources[k][0])  // Add first trial in the group
            }
            return ret;
        }
    }
    function keepOneInGroupAfter(x,sep) { return new KeepOneInGroupAfter(x,sep); }

    Then you can do this:

    Sequence("consent", "practice", rshuffle(keepOneInGroupAfter(startsWith("GreetingsTrial")), "other"), "send", "final")

    Jeremy

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