Sternberg Task Demo Experiment Run Experiment

Sternberg Task

Jaap Murre


If you are a registered user and signed in, you can here copy this script and its stimuli to your own account, where you can edit it and change it in any way you want.

It is absolutely free to register (no credit card info asked!). You can then instantly copy this experiment with one click and edit it, change its accompanying texts, its landing page, stimuli, etc. Invite your colleagues, friends, or students to check out your experiment. There is no limit on how many people can do your experiment, even with a free account.

The catch? There is no catch! Just keep in mind that with a free account, you cannot collect data. For teaching that is usually not a problem. For research, prepaid data collection (unlimited subjects) starts as low as €10.00 for a 10-day period.

// Generate positive set of length 'size' with a probe
// yes/no is not counter-balanced but fully randomized to about 50:50
// E.g., with size = 1, there is still a 50:50 chance of the probe being 1 or not
function getstimulus(size)
{
    var row = shuffle(range(1,10)),         // Array of digits 1 to 9 in random order
        pos = row.slice(0,size),            // First 'size' digits (also store in pos)
        neg = row.slice(size-9),            // Last digits not in positive_set (also store in neg)
        inpositive = Math.random() < 0.5;   // 50% chance of probe in positive set

    return { 
        set: pos,                           // Positive set
        inpositive: inpositive,             // true if probe is in positive set, else false
        probe: inpositive ? pos[randint(size-1)] : neg[randint(9-size-1)] // Keep yes/no ratio about 50:50
    }
}

// Returns a completely randomized design of lengths 1 to 6, where trials for each length are specified
function gettrials(trials_per_length)
{
    var trials = [], i, j;
    
    for (i = 0; i < trials_per_length; i++)
    {
        for (j = 1; j <= 6; j++)
        {
            trials.push(j);
        }
    }
    
    return shuffle(trials);
}

var middle = main.addblock('center',10,100,60)
    .style("border","thin solid lightgrey")
    .style("textAlign","left")
    .style("padding","1em")
    .text("

Instruction

You will see one to six digits appear for a short period." + "Try to remember these. Then they will disappear and a 'probe' digit will appear. " + "Type 'z' for Yes: the probe digit was in the list, " + "or '/' for No: it was not in the list. " + "Be as fast and accurate as you can.
" + "Click the Start button or press the Enter key to start the experiment."); var left = main.addblock('left','bottom',25,10) .style("fontSize","0.8em") .style("color","gray") .text("z key = Yes"); var right = main.addblock('right','bottom',25,10) .style("fontSize","0.8em") .style("color","gray") .text("/ key = No"); var ok = main.addblock('center',70,20,20).button('Start'); ok.await('click'); middle.clear() .style("border","0") .style("fontSize","2em") .style("textAlign","center"); ok.clear(); trials = gettrials(1); var stimulus, positive_set, probe, inpositive, trialno, length, t1, e, score; for (t = 0; t < trials.length; t++) { stimulus = getstimulus(trials[t]); positive_set = stimulus.set.join(' '); // turn array into a space-delimited string with join() probe = stimulus.probe; inpositive = stimulus.inpositive; trialno = t; length = trials[t]; // trials[t] holds the number of items in positive set await(1000); middle.text(positive_set); await(2000); middle.clear(); await(250); middle.text(probe); t1 = now(); e = await("keypress"); rt = now() - t1; // storetrial("RT{stimulus}","{RT}","RT"); middle.clear(); score = 0; if (e.key.toLowerCase() === 'z' && inpositive) { score = 1; } if ((e.key === 'z' || e.key === '?') && !inpositive) { score = 1; } if (score) { middle.text("Correct!"); } else { middle.text("Not correct"); } if (e.key.toLowerCase() !== 'z' && e.key !== '/' && e.key !== '?') { middle.text("Please, press z or /"); score = -1; } //log("RT: RT, Correct: score, length: length, trialno: trialno"); await(1500); middle.clear(); } await(1000); middle.text("Finished!
Thank you for participating!"); await(2000);
This experiment has no files of this type
This experiment has no files of this type
This experiment has no files of this type
This experiment has no YouTube links
This experiment has no files of this type