Spike Toolbox

Using random number generators with the toolbox


This topic explains how the toolbox relies on and interacts with random number generators.

Generators and the toolbox
Using an alternative generator

Generators and the toolbox
The toolbox relies heavily on a random number generator when creating spike train instances. As mentioned elsewhere, these instances are generated by thresholding a random unmber sequence, so the quality of the random sequence will be reflected in the quality of the spike train.

By default, the toolbox uses the built-in rand function supplied by MATLAB. We make no statements about the quality of this generator. Also supplied with the toolbox is a mex implementation of the Mersenne Twister pRNG, which is known to have a very long period and good distribution properties in high dimensions.

When initialising, the toolbox displays a prominent warning about seeding the toolbox RNG. MATLAB uses the same seed whenever it loads; therefore if the same sequence of spike trains is generated every time you start MATLAB, the supposedly "random" sequences will be identical each time. Both the built-in rand function and the toolbox-supplied twister pRNG are deterministic pRNGs. If you instead wrote a mex wrapper for the linux and BSD /dev/rand device (which uses a system-derived entropy pool) this restriction will not hold.


Using an alternative generator
See
Managing spike toolbox options for documentation on retrieving and modifying toolbox settings. This interface is used to change which RNG the toolbox will use for generating random sequeces.

The toolbox option RandomGenerator contains a function handle to the desired RNG. The function identified by this handle must conform to the same calling syntax as rand. For example, to set the toolbox to use the twister generator, you would perform the following steps:

stO = SToptions;
stO.RandomGenerator = @twister;
STOptions(stO);


$Id: spike_tb_randgen.html 1481 2005-08-29 12:41:53Z dylan $