The digit span task is an absolute classic for anyone interested in short term memory. The basic idea of this task is this:

  1. A person is presented with a sequence of two digits

  2. The person needs to repeat the sequence

  3. If the person can repeat the sequence, the a longer sequence is presented

  4. This goes on until the person can not longer repeat the sequence

  5. The longest remembered sequence is the person’s digit span

It is often said that the average person can remember seven digits. This goes back to the work of George A. Miller, as you can read here on Wikipedia.

There are variations on this task. In the current implementation, the sequence length is only increased after the participant has remembered the same length at least two times. This makes the digit span measure more reliable.

Much has been written about the digit span task. It is discussed what it exactly measures (Jones & Macken, 2015).

About this implementation

The digit span task shows some really nice PsyToolkit features. It uses array functions, it works with the mouse only, and so on. Compared to most other experiments, the code looks somewhat more complex. This is mostly because of the way the participants enter the remembered sequence. Even so, it is fairly straightward. Even if you do not understand the code completely, it should be easy to modify.

Run the demo

Data output file

In PsyToolkit, the data output file is simply a textfile. The save line of the PsyToolkit experiment script determines what is being saved in the data output file. Typically, for each experimental trial, you would have exactly one line in your text file, and each number/word on that line gives you the information you need for your data analysis, such as the condition, response speed, and whether an error was made.

The data output is other than in most experiments. In this experiment, there are multiple lines per trial. The reaction time, exactly digit sequences presented and entered are saved. If you are only interested in the ultimate digit span, you can just look at the second number of the last line.

If you embed this experiment yourself, make sure to set only the following two parameters in the analysis section of your experiment as follows:
  1. Which column has dependent variable? set to value 2

  2. Only include last n lines set to value 1

Make sure not to fill in any of the other parameter boxes. This way, the data analysis will only look at the last line of each experiment data file, which contains the participants' best score. There is much other interesting information in the data files. If you really one, you can download all those files to your own computer and analyze further with your own script. But that is not necessary to take out the digitspan result.


If you have a PsyToolkit account, you can upload the zipfile directly to your PsyToolkit account. Watch a video on how to do that. If you want to upload the zipfile into your PsyToolkit account, make sure the file is not automatically uncompressed (some browsers, especially Mac Safari, by default uncompress zip files). Read here how to easily deal with this.

Further reading