# Population coding (Pouget et al., 2010)

A response of a cell can be characterized by an "encoding model" of the stimulus ($s$):

\begin{align}
r_{i} = f_{i}(s) + n_{i}
\end{align}

in which $n$ represents a noise term assumed to follow a normal distribution with a variance proportional to the mean value, $f_{i}(s)$. When the model ("tuning function") is assumed to be gaussian (note to self: is this only for "circular properties" like orientation/motion direction?), it can be written as:

\begin{align}
f_{i}(s) = ke^{-(s - s_{i})^{2}/2\sigma^{2}}
\end{align}



```python
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline

def gaussian_model(s, si=100, k=1, sigma=5):
    """ Computes average activity of cell in response to stimulus `s`
    given the preferred value `si` and scaling faction `k` and width `sigma`.
    """
    return k * np.exp(-(s - si) ** 2 / (2 * sigma ** 2))
    
vals = gaussian_model(np.arange(200))
plt.figure(figsize=(8, 3))
plt.plot(vals)
plt.xlabel('Stimulus/feature value %s' % '$s_{i}$')
plt.ylabel('Activity (a.u.)')
sns.despine()
plt.show()
```

Now, suppose we have 64 cells that fire according to differently tuned tuning functions:


```python
true_si = np.linspace(-180, 180, 64)
true_activity = gaussian_model(s=40, si=true_si, sigma=20) + np.random.normal(0, 0.1, size=true_si.size)
plt.scatter(true_si, true_activity)
plt.title('Activity of 64 neurons')
sns.despine()
plt.show()
```


```python
np.exp(5)
```




    148.4131591025766



0b48949c9c68e41163bb566f7d458b7915b27938
ipynb
Jupyter Notebook
population_coding.ipynb
lukassnoek/random_notebooks
d7df507ce2b6949726c29de0022aae2d0dc583ac
MIT
2018-05-28T13:45:11.000Z
2021-08-31T11:41:34.000Z
population_coding.ipynb
lukassnoek/random_notebooks
d7df507ce2b6949726c29de0022aae2d0dc583ac
MIT
population_coding.ipynb
lukassnoek/random_notebooks
d7df507ce2b6949726c29de0022aae2d0dc583ac
MIT
2018-05-28T13:46:05.000Z
2018-06-11T15:25:59.000Z
Qwen/Qwen-72B
1. YES
2. YES