\documentclass[a4paper,12pt,pdftex]{exam}

\newcommand{\ptitle}{ISI distributions}
\input{../header.tex}
\firstpagefooter{Supervisor: Jan Benda}{phone: 29 74573}%
{email: jan.benda@uni-tuebingen.de}

\begin{document}

\input{../instructions.tex}


%%%%%%%%%%%%%% Questions %%%%%%%%%%%%%%%%%%%%%%%%%

\begin{questions}
  \question You are recording the activity of two neurons in response
  to a constant stimulus $I$ (think of it, for example, of a sound
  wave with intensity $I$ and the activity of an auditory neuron).

  For different inputs $I$ the interspike interval ($T$) distribution looks
  quite different. You want to compare these distributions to
  the following three standard distributions.

  The first is the exponential distribution of a Poisson spike train:
  \begin{equation}
    \label{exppdf}
    p_{exp}(T) = \lambda e^{-\lambda T}
  \end{equation}
  where $\lambda$ is the mean firing rate of the response.

  The second distribution is the inverse Gaussian:
  \begin{equation}
    \label{invgauss}
    p_\mathrm{ig}(T) = \frac{1}{\sqrt{4 \pi D T^{3}}} \exp \left[ - \frac{(T - \mu)^{2} }{4 D T \mu^{2}} \right]
  \end{equation}
  where $\mu$ is the mean interspike interval and
  $D=\textrm{var}(T)/(2\mu^3)$ 
  is the so called diffusion coefficient.

  The third one was derived for neurons driven with colored noise:
  \begin{equation}\label{pcn}
    p_\mathrm{cn}(T)=\frac{1}{2\tau\sqrt{4\pi\epsilon\gamma_1^3}}\exp\left[-\frac{(T-\mu)^2}{4\epsilon\tau^2\gamma_1}\right]\left\{\frac{[(\mu-T)\gamma_2+2\gamma_1\tau]^2}{2\gamma_1\tau^2}-\epsilon(\gamma_2^2-2\gamma_1e^{-T/\tau})\right\} 
  \end{equation}
  with $\gamma_1(T)=T/\tau+e^{-T/\tau}-1$, $\gamma_2(T)=1-e^{-T/\tau}$
  and correlation time of the colored noise $\tau$.  
  Eq.~(\ref{pcn}) thus has the three parameter $\mu$, $\epsilon>0$, and $\tau$.

  The squared coefficient of variation (standard deviation of the
  interspike intervals divided by their mean) of the density
  eq.~(\ref{pcn}) is given by
  \begin{equation}
    \label{cvpcn}
    C_V^2=\frac{2}{\delta}\left[\epsilon\left(1-\frac{1-e^{-\delta}}{\delta}\right)+\epsilon^2\left(e^{-\delta}+\frac{(1-e^{-\delta})(1-2e^{-\delta})}{\delta}\right)\right]
  \end{equation}
  with $\delta=\mu/\tau$. 

  The two neurons are implemented in the files \texttt{pifouspikes.m}
  and \texttt{lifouspikes.m}.  Call them with the following
  parameters:
    \begin{lstlisting}
trials = 10;
tmax = 50.0;
input = 10.0;  % the input I
Dnoise = 1.0;  % noise strength
outau = 1.0;   % correlation time of the noise in seconds

spikespif = pifouspikes( trials, input, tmax, Dnoise, outau );
spikeslif = lifouspikes( trials, input, tmax, Dnoise, outau );
    \end{lstlisting}
    The returned \texttt{spikespif} and \texttt{spikeslif} are cell
    arrays with \texttt{trials} elements, each being a vector of spike
    times (in seconds) computed for a duration of \texttt{tmax}
    seconds.  The input is set via the \texttt{input} variable.
  \begin{parts}
    \part For both model neurons find the inputs $I_i$ required to
    make them fire with a mean rate of 10, 20, 50, and 100\,Hz.

    \part Compute interspike interval distributions of the two model
    neurons for these inputs $I_i$.

    \part Compare the interspike interval distributions with the exponential 
    distribution eq.~(\ref{exppdf}) and the inverse Gaussian
    eq.~(\ref{invgauss}) by measuring their parameters from the
    interspike intervals. How well do they describe the real
    distributions for the different conditions?

    \part Also fit eq.~(\ref{pcn}) to the data using maximum (log)-likelihood. 

    How well does this function describe the data?

    Compare the fitted value for $\tau$ with the one used for the
    model (\texttt{outau}).


    \uplevel{If you still have time you can continue with the following question:}

    \part Compare the measured coefficient of variation with eq.~(\ref{cvpcn}).

    \part Repeat your analysis for different values of the intrinsic
    noise strengh of the neurons \texttt{Dnoise}. Increase or decrease
    it in factors of ten.

 \end{parts}

\end{questions}

\end{document}