\documentclass[addpoints,10pt]{exam}
\usepackage{url}
\usepackage{color}
\usepackage{hyperref}

\pagestyle{headandfoot}
\runningheadrule
\firstpageheadrule
\firstpageheader{Scientific Computing}{Project Assignment}{11/05/2014
  -- 11/06/2014}
%\runningheader{Homework 01}{Page \thepage\ of \numpages}{23. October 2014}
\firstpagefooter{}{}{}
\runningfooter{}{}{}
\pointsinmargin
\bracketedpoints

%\printanswers
%\shadedsolutions

%%%%% listings %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{listings}
\lstset{
 basicstyle=\ttfamily,
 numbers=left,
 showstringspaces=false,
 language=Matlab,
 breaklines=true,
 breakautoindent=true,
 columns=flexible,
 frame=single,
% captionpos=t,
 xleftmargin=2em,
 xrightmargin=1em,
% aboveskip=10pt,
 %title=\lstname,
% title={\protect\filename@parse{\lstname}\protect\filename@base.\protect\filename@ext}
 }


\begin{document}
%%%%%%%%%%%%%%%%%%%%% Submission instructions %%%%%%%%%%%%%%%%%%%%%%%%%
\sffamily
% \begin{flushright}
% \gradetable[h][questions]
% \end{flushright}

\begin{center}
  \input{../disclaimer.tex}
\end{center}

%%%%%%%%%%%%%% 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$).

  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$. 

  \begin{parts}
    \part 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

      spikes = pifouspikes( trials, input, tmax, Dnoise, outau );
    \end{lstlisting}
    The returned \texttt{spikes} is a cell array 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.

    \part Find for both model neurons the inputs $I_i$ required to make the 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 theu describe the real
    distributions for the different conditions?

    \part Also fit eq.~(\ref{pcn}) to the data. Here you need to apply a non-linear fit algorithm.

    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}