This code relates to my work on population coding models [1, 2]. I've made the relevant MATLAB functions available for download here [zip].

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 [3]. 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 [1] and perceptual [2] tasks.

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 [1]) 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 [2].

A demonstration of using the function to fit data is included in the package (demo.m), including an example of incorporating swap errors [4, 5].

[1] Bays PM. Noise in neural populations accounts for errors in working memory. *Journal of Neuroscience* 34(10): 3632-3645 (2014) [pdf]

[2] Bays PM. A signature of neural coding at human perceptual limits. *Journal of Vision* 16(11): 4 (2016) [pdf]

[3] Pouget A, Dayan P & Zemel R. Information processing with population codes. *Nature Reviews Neuroscience* 1:2 125-32 (2000)

[4] Bays PM, Catalao RFG & Husain M. The precision of visual working memory is set by allocation of a shared resource. *Journal of Vision* 9(10): 7, 1-11 (2009) [pdf] [code]

[5] Bays PM. Evaluating and excluding swap errors in analogue tests of working memory. *Scientific Reports* 6: 19203 (2016) [pdf]