This code is released under a GNU General Public License: feel free to use and adapt these functions as you like, but credit should be given if they contribute to your work, by citing:
Bays PM. Noise in neural populations accounts for errors in working memory. Journal of Neuroscience 34(10): 3632-3645 (2014)
If you refer to this code directly, please also include the URL of this webpage, or my homepage bayslab.com.
Population coding describes a method by which information can be encoded in, and recovered from, the combined activity of a pool of neurons . The following functions provide methods for obtaining the error distributions predicted by a standard model of population encoding and decoding. My work has shown that these predicted distributions closely match those observed in human working memory  and perceptual  tasks. The neural resource model incorporates normalization into the standard model, accounting for changes in working memory performance with set size.
According to the population coding model (right), stimulus values are represented in the spiking activity of a population of neurons with bell-shaped (Von Mises) tuning curves. Preferred values that elicit maximum activity are evenly distributed throughout the circular space of possible values. Spikes are generated probabilistically according to a Poisson process. Decoding is modelled as maximum likelihood (ML) estimation based on the spikes generated in a fixed temporal window. The model is based on the large-population limit, i.e. as the number of neurons becomes infinite.
The model has two free parameters: κ, the tuning width (equal to ω-1 in ) and ξ, the average summed population activity (gain) during the decoding window. The function
P = JN14_pdf(THETA, K, XI)
returns the probability density function of the distribution of errors evaluated at values in THETA (given in radians, in the range [−π, π]). The model can be fit to data using e.g. fminsearch in the Optimization toolbox.
The package also includes the cumulative density function JN14_cdf which can be used to generate simulated data under the model.
The functions calculate the distribution of the resultant direction of a random walk where each step is chosen from a Von Mises distribution with concentration κ, and the number of steps is Poisson distributed with mean ξ. This is mathematically equivalent to the output of the population coding model described above; for proof and further details see .
 Bays PM. Noise in neural populations accounts for errors in working memory. Journal of Neuroscience 34(10): 3632-3645 (2014) [pdf]
 Bays PM. A signature of neural coding at human perceptual limits. Journal of Vision 16(11): 4 (2016) [pdf]
 Bays PM. Evaluating and excluding swap errors in analogue tests of working memory. Scientific Reports 6: 19203 (2016) [pdf]