Using Seeds to Control Randomization in ERPLAB - ucdavis/erplab GitHub Wiki

MATLAB’s random number generator is used in parts of the ERPLAB code (e.g., for adding random noise to data) and in custom scripts (e.g., for permutation analyses). The random number generator is not truly random, but instead uses a deterministic algorithm that produces a sequence of numbers that appear random. The random number generator is initialized with a “seed” value. The same sequence is always produced for a given seed, but the sequences for different seeds are very different, even if the seed values are similar. A common approach is to use a numeric representation of the date and time as the seed every time Matlab is launched. This leads to sequences that appear to be nearly random. However, it is useful to specify a known seed if you wish to be able to perfectly reproduce a given result. For example, if you post a script used for an analysis that involves the random number generator, and you want other researchers to be able to obtain exactly the same results you obtained by running your script, you can provide a constant seed to the random number generator at the beginning of the script. The random number generator will then produce the same sequence for other other researchers that it produced for you.

However, it is often advantageous to use a random seed to generate numbers. For example, if you want to repeat a given analysis many times with different randomized noise, using the same seed each time would give you the same “noise” each time.

By default, MATLAB and ERPLAB will use a "set" startup seed on every startup to generate random numbers in their routines. If you are writing your own scripts, you can override this by providing your own seed value (see MATLAB's documentation). If you are using the ERPLAB GUI, some of our routines provide an option for maintaining a constant seed or re-seeing the random number generator each time the routine is run.