New exercise for point processes

This commit is contained in:
Jan Benda 2015-10-26 23:35:23 +01:00
parent 54a86daf60
commit ef9521a1fa
24 changed files with 438 additions and 124 deletions

View File

@ -18,18 +18,17 @@ function [ counts, bins ] = counthist( spikes, w )
end end
% histogram of spike counts: % histogram of spike counts:
maxn = max( n ); maxn = max( n );
[counts, bins ] = hist( n, 0:1:maxn+1 ); [counts, bins ] = hist( n, 0:1:maxn+10 );
counts = counts / sum( counts ); counts = counts / sum( counts );
if nargout == 0 if nargout == 0
bar( bins, counts ); bar( bins, counts );
hold on; hold on;
% Poisson distribution: % Poisson distribution:
rate = mean( r ); rate = mean( r );
x = 0:1:20; x = 0:1:maxn+10;
l = rate*w; l = rate*w;
y = l.^x.*exp(-l)./factorial(x); y = l.^x.*exp(-l)./factorial(x);
plot( x, y, 'r', 'LineWidth', 3 ); plot( x, y, 'r', 'LineWidth', 3 );
xlim( [ 0 20 ] );
hold off; hold off;
xlabel( 'counts k' ); xlabel( 'counts k' );
ylabel( 'P(k)' ); ylabel( 'P(k)' );

View File

@ -24,9 +24,9 @@ function isihist( isis, binwidth )
misi = mean( isis ); misi = mean( isis );
sdisi = std( isis ); sdisi = std( isis );
disi = sdisi^2.0/2.0/misi^3; disi = sdisi^2.0/2.0/misi^3;
text( 0.5, 0.6, sprintf( 'mean=%.1f ms', 1000.0*misi ), 'Units', 'normalized' ) text( 0.95, 0.8, sprintf( 'mean=%.1f ms', 1000.0*misi ), 'Units', 'normalized', 'HorizontalAlignment', 'right' )
text( 0.5, 0.5, sprintf( 'std=%.1f ms', 1000.0*sdisi ), 'Units', 'normalized' ) text( 0.95, 0.7, sprintf( 'std=%.1f ms', 1000.0*sdisi ), 'Units', 'normalized', 'HorizontalAlignment', 'right' )
text( 0.5, 0.4, sprintf( 'CV=%.2f', sdisi/misi ), 'Units', 'normalized' ) text( 0.95, 0.6, sprintf( 'CV=%.2f', sdisi/misi ), 'Units', 'normalized', 'HorizontalAlignment', 'right' )
%text( 0.5, 0.3, sprintf( 'D=%.1f Hz', disi ), 'Units', 'normalized' ) %text( 0.5, 0.3, sprintf( 'D=%.1f Hz', disi ), 'Units', 'normalized' )
end end

Binary file not shown.

View File

@ -3,8 +3,8 @@ function spikes = lifadaptspikes( trials, input, tmaxdt, D, tauadapt, adaptincr
% with an adaptation current % with an adaptation current
% trials: the number of trials to be generated % trials: the number of trials to be generated
% input: the stimulus either as a single value or as a vector % input: the stimulus either as a single value or as a vector
% tmaxdt: in case of a single value stimulus the duration of a trial % tmaxdt: in case of a single value stimulus: the duration of a trial
% in case of a vector as a stimulus the time step % in case of a vector as a stimulus: the time step
% D: the strength of additive white noise % D: the strength of additive white noise
% tauadapt: adaptation time constant % tauadapt: adaptation time constant
% adaptincr: adaptation strength % adaptincr: adaptation strength

Binary file not shown.

View File

@ -2,8 +2,8 @@ function spikes = lifspikes( trials, input, tmaxdt, D )
% Generate spike times of a leaky integrate-and-fire neuron % Generate spike times of a leaky integrate-and-fire neuron
% trials: the number of trials to be generated % trials: the number of trials to be generated
% input: the stimulus either as a single value or as a vector % input: the stimulus either as a single value or as a vector
% tmaxdt: in case of a single value stimulus the duration of a trial % tmaxdt: in case of a single value stimulus: the duration of a trial
% in case of a vector as a stimulus the time step % in case of a vector as a stimulus: the time step
% D: the strength of additive white noise % D: the strength of additive white noise
tau = 0.01; tau = 0.01;

View File

@ -0,0 +1,20 @@
function spikes = lifspikesoustim(trials, tmax, D, Iou, Dou, tauou )
% Generate spike times of a leaky integrate-and-fire neuron with frozen
% Ohrnstein-Uhlenbeck stimulus
% trials: the number of trials to be generated
% tmax: the duration of a trial
% D: the strength of additive white noise
% Iou: the mean input
% Dou: noise strength of the frozen OU noise
% tauou: time constant of the OU noise
dt = 1e-4;
input = zeros(round(tmax/dt), 1);
n = 0.0;
noise = sqrt(2.0*Dou)*randn(length(input), 1)/sqrt(dt);
for i=1:length(noise)
n = n + ( - n + noise(i))*dt/tauou;
input(i) = Iou + n;
end
spikes = lifspikes(trials, input, dt, D );
end

Binary file not shown.

View File

@ -0,0 +1,24 @@
w = 0.1;
cmax = 8;
pmax = 0.5;
subplot(1, 3, 1);
counthist(poissonspikes, w);
xlim([0 cmax])
set(gca, 'XTick', 0:2:cmax)
ylim([0 pmax])
title('Poisson');
subplot(1, 3, 2);
counthist(pifouspikes, w);
xlim([0 cmax])
set(gca, 'XTick', 0:2:cmax)
ylim([0 pmax])
title('PIF OU');
subplot(1, 3, 3);
counthist(lifadaptspikes, w);
xlim([0 cmax])
set(gca, 'XTick', 0:2:cmax)
ylim([0 pmax])
title('LIF adapt');
savefigpdf(gcf, 'counthist.pdf', 20, 7);

View File

@ -0,0 +1,19 @@
maxisi = 300.0;
subplot(1, 3, 1);
poissonisis = isis(poissonspikes);
isihist(poissonisis, 0.001);
xlim([0, maxisi])
title('Poisson');
subplot(1, 3, 2);
pifouisis = isis(pifouspikes);
isihist(pifouisis, 0.001);
xlim([0, maxisi])
title('PIF OU');
subplot(1, 3, 3);
lifadaptisis = isis(lifadaptspikes);
isihist(lifadaptisis, 0.001);
xlim([0, maxisi])
title('LIF adapt');
savefigpdf(gcf, 'isihist.pdf', 20, 7);

View File

@ -0,0 +1,17 @@
maxlag = 10;
rrange = [-0.5, 1.05];
subplot(1, 3, 1);
isiserialcorr(poissonisis, maxlag);
ylim(rrange)
title('Poisson');
subplot(1, 3, 2);
isiserialcorr(pifouisis, maxlag);
ylim(rrange)
title('PIF OU');
subplot(1, 3, 3);
isiserialcorr(lifadaptisis, maxlag);
ylim(rrange)
title('LIF adapt');
savefigpdf(gcf, 'serialcorr.pdf', 20, 7);

View File

@ -0,0 +1,13 @@
subplot(1, 3, 1);
spikeraster(poissonspikes, 1.0);
title('Poisson');
subplot(1, 3, 2);
spikeraster(pifouspikes, 1.0);
title('PIF OU');
subplot(1, 3, 3);
spikeraster(lifadaptspikes, 1.0);
title('LIF adapt');
savefigpdf(gcf, 'spikeraster.pdf', 15, 5);

Binary file not shown.

View File

@ -14,7 +14,7 @@ function spikes = poissonspikes( trials, rate, tmax )
end end
spikes = cell(trials, 1); spikes = cell(trials, 1);
for k=1:trials for k=1:trials
x = rand( 1, round(tmax/dt) ); % uniform random numbers for each bin x = rand(round(tmax/dt), 1); % uniform random numbers for each bin
spikes{k} = find(x < p) * dt; spikes{k} = find(x < p) * dt;
end end
end end

View File

@ -0,0 +1,14 @@
function p = psth(spikes, dt, tmax)
% plots a PSTH of the spikes with binwidth dt
t = 0.0:dt:tmax+dt;
p = zeros(1, length(t));
for k=1:length(spikes)
times = spikes{k};
[h, b] = hist(times, t);
p = p + h;
end
p = p/length(spikes)/dt;
t(end) = [];
p(end) = [];
plot(t, p);
end

View File

@ -1,15 +1,24 @@
function spikeraster( spikes ) function spikeraster(spikes, tmax)
% Display a spike raster of the spike times given in spikes. % Display a spike raster of the spike times given in spikes.
% spikes: a cell array of vectors of spike times % spikes: a cell array of vectors of spike times
% tmax: plot spike raster upto tmax seconds
ntrials = length(spikes); ntrials = length(spikes);
for k = 1:ntrials for k = 1:ntrials
times = 1000.0*spikes{k}; % conversion to ms times = spikes{k};
times = times(times<tmax);
if tmax < 1.5
times = 1000.0*times; % conversion to ms
end
for i = 1:length( times ) for i = 1:length( times )
line([times(i) times(i)],[k-0.4 k+0.4], 'Color', 'k' ); line([times(i) times(i)],[k-0.4 k+0.4], 'Color', 'k' );
end end
end end
if tmax < 1.5
xlabel( 'Time [ms]' ); xlabel( 'Time [ms]' );
else
xlabel( 'Time [s]' );
end
ylabel( 'Trials'); ylabel( 'Trials');
ylim( [ 0.3 ntrials+0.7 ] ) ylim( [ 0.3 ntrials+0.7 ] )

View File

@ -0,0 +1,12 @@
function r = spikerate(spikes, duration)
% returns the average spike rate of the spikes
% for the first duration seconds
% spikes: a cell array of vectors of spike times
rates = zeros(length(spikes),1);
for k = 1:length(spikes)
times = spikes{k};
rates(k) = sum(times<duration)/duration;
end
r = mean(rates);
end

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -11,11 +11,11 @@
\usepackage[left=20mm,right=20mm,top=25mm,bottom=25mm]{geometry} \usepackage[left=20mm,right=20mm,top=25mm,bottom=25mm]{geometry}
\pagestyle{headandfoot} \pagestyle{headandfoot}
\ifprintanswers \ifprintanswers
\newcommand{\stitle}{: L\"osungen} \newcommand{\stitle}{L\"osungen}
\else \else
\newcommand{\stitle}{} \newcommand{\stitle}{\"Ubung}
\fi \fi
\header{{\bfseries\large \"Ubung 6\stitle}}{{\bfseries\large Statistik}}{{\bfseries\large 27. Oktober, 2015}} \header{{\bfseries\large \stitle}}{{\bfseries\large Punktprozesse}}{{\bfseries\large 27. Oktober, 2015}}
\firstpagefooter{Prof. Dr. Jan Benda}{Phone: 29 74573}{Email: \firstpagefooter{Prof. Dr. Jan Benda}{Phone: 29 74573}{Email:
jan.benda@uni-tuebingen.de} jan.benda@uni-tuebingen.de}
\runningfooter{}{\thepage}{} \runningfooter{}{\thepage}{}
@ -89,111 +89,96 @@ jan.benda@uni-tuebingen.de}
\begin{questions} \begin{questions}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\question \qt{Homogeneous Poisson process} \question \qt{Statistik von Spiketrains}
We use the Poisson process to generate spike trains on which we can test and imrpove some In Ilias findet ihr die Dateien \code{poisson.mat},
standard analysis functions. \code{pifou.mat}, und \code{lifadapt.mat}. Jede dieser Dateien
enth\"alt mehrere Trials von Spiketrains von einer bestimmten Art
A homogeneous Poisson process of rate $\lambda$ (measured in Hertz) is a point process von Neuron. Die Spikezeiten sind in Sekunden gemessen.
where the probability of an event is independent of time $t$ and independent of previous events.
The probability $P$ of an event within a bin of width $\Delta t$ is Mit den folgenden Aufgaben wollen wir die Statistik der Spiketrains
\[ P = \lambda \cdot \Delta t \] der drei Neurone miteinander vergleichen.
for sufficiently small $\Delta t$.
\begin{parts} \begin{parts}
\part Lade die Spiketrains aus den drei Dateien. Achte darauf, dass sie verschiedene
\part Write a function that generates $n$ homogeneous Poisson spike trains of a given duration $T_{max}$ Variablennamen bekommen.
with rate $\lambda$.
\begin{solution} \begin{solution}
\lstinputlisting{hompoissonspikes.m} \begin{lstlisting}
clear all
load poisson.mat
whos
poissonspikes = spikes;
load pifou.mat;
pifouspikes = spikes;
load lifadapt.mat;
lifadaptspikes = spikes;
clear spikes;
\end{lstlisting}
\end{solution} \end{solution}
\part Using this function, generate a few trials and display them in a raster plot. \part Schreibe eine Funktion, die die Spikezeiten der ersten
\code{tmax} Sekunden in einem Rasterplot visualisiert. In jeder
Zeile des Rasterplots wird ein Spiketrain dargestellt. Jeder
einzelne Spike wird als senkrechte Linie zu der Zeit des
Auftretens des Spikes geplottet. Benutze die Funktion, um die
Spikeraster der ersten 1\,s der drei Neurone zu plotten.
\begin{solution} \begin{solution}
\lstinputlisting{../code/spikeraster.m} \lstinputlisting{../code/spikeraster.m}
\begin{lstlisting} \lstinputlisting{../code/plotspikeraster.m}
spikes = hompoissonspikes( 10, 100.0, 0.5 );
spikeraster( spikes )
\end{lstlisting}
\mbox{}\\[-3ex] \mbox{}\\[-3ex]
\colorbox{white}{\includegraphics[width=0.7\textwidth]{poissonraster100hz}} \colorbox{white}{\includegraphics[width=1\textwidth]{spikeraster}}
\end{solution} \end{solution}
\part Write a function that extracts a single vector of interspike intervals \part Schreibe eine Funktion, die einen einzigen Vektor mit den Interspike-Intervallen
from the spike times returned by the first function. aller Trials von Spikezeiten zur\"uckgibt.
\begin{solution} \begin{solution}
\lstinputlisting{../code/isis.m} \lstinputlisting{../code/isis.m}
\end{solution} \end{solution}
\part Write a function that plots the interspike-interval histogram \part Schreibe eine Funktion, die ein normiertes Histogramm aus
from a vector of interspike intervals. The function should also einem Vektor von Interspike-Intervallen, gegeben in Sekunden,
compute the mean, the standard deviation, and the CV of the intervals berechnet und dieses mit richtiger Achsenbeschriftung plottet. Die
and display the values in the plot. Interspike-Intervalle sollen dabei in Millisekunden angegeben
\begin{solution} werden. Die Funktion soll ausserdem den Mittelwert, die Standardabweichung,
\lstinputlisting{../code/isihist.m} und den Variationskoeffizienten der Interspike Intervalle berechnen
\end{solution} und diese im Plot mit angeben.
\part Compute histograms for Poisson spike trains with rate
$\lambda=100$\,Hz. Play around with $T_{max}$ and $n$ and the bin width
(start with 1\,ms) of the histogram.
How many
interspike intervals do you approximately need to get a ``nice''
histogram? How long do you need to record from the neuron?
\begin{solution}
About 5000 intervals for 25 bins. This corresponds to a $5000 / 100\,\hertz = 50\,\second$ recording
of a neuron firing with 100\,\hertz.
\end{solution}
\part Compare the histogram with the true distribution of intervals $T$ of the Poisson process Benutze diese und die vorherige Funktion, um die Interspike-Intervall Verteilung
\[ p(T) = \lambda e^{-\lambda T} \] der drei Neurone zu vergleichen.
for various rates $\lambda$.
\begin{solution} \begin{solution}
\lstinputlisting{hompoissonisih.m} \lstinputlisting{../code/isihist.m}
\colorbox{white}{\includegraphics[width=0.48\textwidth]{poissonisih100hz}} \lstinputlisting{../code/plotisih.m}
\colorbox{white}{\includegraphics[width=0.48\textwidth]{poissonisih20hz}} \mbox{}\\[-3ex]
\end{solution} \colorbox{white}{\includegraphics[width=1\textwidth]{isihist}}
\part What happens if you make the bin width of the histogram smaller than $\Delta t$
used for generating the Poisson spikes?
\begin{solution}
The bins between the discretization have zero entries. Therefore
the other ones become higher than they should be.
\end{solution}
\part Plot the mean interspike interval, the corresponding standard deviation, and the CV
as a function of the rate $\lambda$ of the Poisson process.
Compare the ../code with the theoretical expectations for the dependence on $\lambda$.
\begin{solution}
\lstinputlisting{hompoissonisistats.m}
\colorbox{white}{\includegraphics[width=0.98\textwidth]{poissonisistats}}
\end{solution} \end{solution}
\part Write a function that computes serial correlations for the interspike intervals \part Schreibe eine Funktion, die die Seriellen Korrelationen der
for a range of lags. Interspike Intervalle f\"ur lags bis zu \code{maxlag} berechnet
The serial correlations $\rho_k$ at lag $k$ are defined as und plottet. Die Seriellen Korrelationen $\rho_k$ f\"ur lag $k$
\[ \rho_k = \frac{\langle (T_{i+k} - \langle T \rangle)(T_i - \langle T \rangle) \rangle}{\langle (T_i - \langle T \rangle)^2\rangle} = \frac{{\rm cov}(T_{i+k}, T_i)}{{\rm var}(T_i)} \] der Interspike Intervalle $T_i$ sind wie folgt definiert:
Use this function to show that interspike intervals of Poisson spikes are independent. \[ \rho_k = \frac{\langle (T_{i+k} - \langle T \rangle)(T_i -
\langle T \rangle) \rangle}{\langle (T_i - \langle T
\rangle)^2\rangle} = \frac{{\rm cov}(T_{i+k}, T_i)}{{\rm
var}(T_i)} = {\rm corrcoef}(T_{i+k}, T_i) \] Benutze dies Funktion,
um die Interspike Intervall Korrelationen der drei Neurone zu
vergleichen.
\begin{solution} \begin{solution}
\lstinputlisting{../code/isiserialcorr.m} \lstinputlisting{../code/isiserialcorr.m}
\colorbox{white}{\includegraphics[width=0.98\textwidth]{poissonserial100hz}} \lstinputlisting{../code/plotserialcorr.m}
\colorbox{white}{\includegraphics[width=1\textwidth]{serialcorr}}
\end{solution} \end{solution}
\part Write a function that generates from spike times \part Schreibe eine Funktion, die aus Spikezeiten
a histogram of spike counts in a count window of given duration $W$. Histogramme aus der Anzahl von Spikes, die in Fenstern gegebener L\"ange $W$
The function should also plot the Poisson distribution gez\"ahlt werden, erzeugt und plottet. Zus\"atzlich soll die Funktion
\[ P(k) = \frac{(\lambda W)^ke^{\lambda W}}{k!} \] die Poisson-Verteilung
for the rate $\lambda$ determined from the spike trains. \[ P(k) = \frac{(\lambda W)^ke^{\lambda W}}{k!} \] mit der Rate
$\lambda$, die aus den Daten bestimmt werden kann, mit zu dem
Histogramm hineinzeichen.
\begin{solution} \begin{solution}
\lstinputlisting{../code/counthist.m} \lstinputlisting{../code/counthist.m}
\colorbox{white}{\includegraphics[width=0.48\textwidth]{poissoncounthistdist100hz10ms}} \lstinputlisting{../code/plotcounthist.m}
\colorbox{white}{\includegraphics[width=0.48\textwidth]{poissoncounthistdist100hz100ms}} \colorbox{white}{\includegraphics[width=1\textwidth]{counthist}}
\end{solution} \end{solution}
\part Write a function that computes mean count, variance of count and the corresponding Fano factor
for a range of count window durations. The function should generate tow plots: one plotting
the count variance against the mean, the other one the Fano factor as a function of the window duration.
\begin{solution}
\lstinputlisting{../code/fano.m}
\colorbox{white}{\includegraphics[width=0.98\textwidth]{poissonfano100hz}}
\end{solution}
\end{parts} \end{parts}

View File

@ -0,0 +1,202 @@
\documentclass[12pt,a4paper,pdftex]{exam}
\usepackage[german]{babel}
\usepackage{pslatex}
\usepackage[mediumspace,mediumqspace,Gray]{SIunits} % \ohm, \micro
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage[breaklinks=true,bookmarks=true,bookmarksopen=true,pdfpagemode=UseNone,pdfstartview=FitH,colorlinks=true,citecolor=blue]{hyperref}
%%%%% layout %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[left=20mm,right=20mm,top=25mm,bottom=25mm]{geometry}
\pagestyle{headandfoot}
\ifprintanswers
\newcommand{\stitle}{: L\"osungen}
\else
\newcommand{\stitle}{}
\fi
\header{{\bfseries\large \"Ubung 6\stitle}}{{\bfseries\large Statistik}}{{\bfseries\large 27. Oktober, 2015}}
\firstpagefooter{Prof. Dr. Jan Benda}{Phone: 29 74573}{Email:
jan.benda@uni-tuebingen.de}
\runningfooter{}{\thepage}{}
\setlength{\baselineskip}{15pt}
\setlength{\parindent}{0.0cm}
\setlength{\parskip}{0.3cm}
\renewcommand{\baselinestretch}{1.15}
%%%%% listings %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{listings}
\lstset{
language=Matlab,
basicstyle=\ttfamily\footnotesize,
numbers=left,
numberstyle=\tiny,
title=\lstname,
showstringspaces=false,
commentstyle=\itshape\color{darkgray},
breaklines=true,
breakautoindent=true,
columns=flexible,
frame=single,
xleftmargin=1em,
xrightmargin=1em,
aboveskip=10pt
}
%%%%% math stuff: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{bm}
\usepackage{dsfont}
\newcommand{\naZ}{\mathds{N}}
\newcommand{\gaZ}{\mathds{Z}}
\newcommand{\raZ}{\mathds{Q}}
\newcommand{\reZ}{\mathds{R}}
\newcommand{\reZp}{\mathds{R^+}}
\newcommand{\reZpN}{\mathds{R^+_0}}
\newcommand{\koZ}{\mathds{C}}
%%%%% page breaks %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\continue}{\ifprintanswers%
\else
\vfill\hspace*{\fill}$\rightarrow$\newpage%
\fi}
\newcommand{\continuepage}{\ifprintanswers%
\newpage
\else
\vfill\hspace*{\fill}$\rightarrow$\newpage%
\fi}
\newcommand{\newsolutionpage}{\ifprintanswers%
\newpage%
\else
\fi}
%%%%% new commands %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\qt}[1]{\textbf{#1}\\}
\newcommand{\pref}[1]{(\ref{#1})}
\newcommand{\extra}{--- Zusatzaufgabe ---\ \mbox{}}
\newcommand{\code}[1]{\texttt{#1}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\input{instructions}
\begin{questions}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\question \qt{Homogeneous Poisson process}
We use the Poisson process to generate spike trains on which we can test and imrpove some
standard analysis functions.
A homogeneous Poisson process of rate $\lambda$ (measured in Hertz) is a point process
where the probability of an event is independent of time $t$ and independent of previous events.
The probability $P$ of an event within a bin of width $\Delta t$ is
\[ P = \lambda \cdot \Delta t \]
for sufficiently small $\Delta t$.
\begin{parts}
\part Write a function that generates $n$ homogeneous Poisson spike trains of a given duration $T_{max}$
with rate $\lambda$.
\begin{solution}
\lstinputlisting{hompoissonspikes.m}
\end{solution}
\part Using this function, generate a few trials and display them in a raster plot.
\begin{solution}
\lstinputlisting{../code/spikeraster.m}
\begin{lstlisting}
spikes = hompoissonspikes( 10, 100.0, 0.5 );
spikeraster( spikes )
\end{lstlisting}
\mbox{}\\[-3ex]
\colorbox{white}{\includegraphics[width=0.7\textwidth]{poissonraster100hz}}
\end{solution}
\part Write a function that extracts a single vector of interspike intervals
from the spike times returned by the first function.
\begin{solution}
\lstinputlisting{../code/isis.m}
\end{solution}
\part Write a function that plots the interspike-interval histogram
from a vector of interspike intervals. The function should also
compute the mean, the standard deviation, and the CV of the intervals
and display the values in the plot.
\begin{solution}
\lstinputlisting{../code/isihist.m}
\end{solution}
\part Compute histograms for Poisson spike trains with rate
$\lambda=100$\,Hz. Play around with $T_{max}$ and $n$ and the bin width
(start with 1\,ms) of the histogram.
How many
interspike intervals do you approximately need to get a ``nice''
histogram? How long do you need to record from the neuron?
\begin{solution}
About 5000 intervals for 25 bins. This corresponds to a $5000 / 100\,\hertz = 50\,\second$ recording
of a neuron firing with 100\,\hertz.
\end{solution}
\part Compare the histogram with the true distribution of intervals $T$ of the Poisson process
\[ p(T) = \lambda e^{-\lambda T} \]
for various rates $\lambda$.
\begin{solution}
\lstinputlisting{hompoissonisih.m}
\colorbox{white}{\includegraphics[width=0.48\textwidth]{poissonisih100hz}}
\colorbox{white}{\includegraphics[width=0.48\textwidth]{poissonisih20hz}}
\end{solution}
\part What happens if you make the bin width of the histogram smaller than $\Delta t$
used for generating the Poisson spikes?
\begin{solution}
The bins between the discretization have zero entries. Therefore
the other ones become higher than they should be.
\end{solution}
\part Plot the mean interspike interval, the corresponding standard deviation, and the CV
as a function of the rate $\lambda$ of the Poisson process.
Compare the ../code with the theoretical expectations for the dependence on $\lambda$.
\begin{solution}
\lstinputlisting{hompoissonisistats.m}
\colorbox{white}{\includegraphics[width=0.98\textwidth]{poissonisistats}}
\end{solution}
\part Write a function that computes serial correlations for the interspike intervals
for a range of lags.
The serial correlations $\rho_k$ at lag $k$ are defined as
\[ \rho_k = \frac{\langle (T_{i+k} - \langle T \rangle)(T_i - \langle T \rangle) \rangle}{\langle (T_i - \langle T \rangle)^2\rangle} = \frac{{\rm cov}(T_{i+k}, T_i)}{{\rm var}(T_i)} \]
Use this function to show that interspike intervals of Poisson spikes are independent.
\begin{solution}
\lstinputlisting{../code/isiserialcorr.m}
\colorbox{white}{\includegraphics[width=0.98\textwidth]{poissonserial100hz}}
\end{solution}
\part Write a function that generates from spike times
a histogram of spike counts in a count window of given duration $W$.
The function should also plot the Poisson distribution
\[ P(k) = \frac{(\lambda W)^ke^{\lambda W}}{k!} \]
for the rate $\lambda$ determined from the spike trains.
\begin{solution}
\lstinputlisting{../code/counthist.m}
\colorbox{white}{\includegraphics[width=0.48\textwidth]{poissoncounthistdist100hz10ms}}
\colorbox{white}{\includegraphics[width=0.48\textwidth]{poissoncounthistdist100hz100ms}}
\end{solution}
\part Write a function that computes mean count, variance of count and the corresponding Fano factor
for a range of count window durations. The function should generate tow plots: one plotting
the count variance against the mean, the other one the Fano factor as a function of the window duration.
\begin{solution}
\lstinputlisting{../code/fano.m}
\colorbox{white}{\includegraphics[width=0.98\textwidth]{poissonfano100hz}}
\end{solution}
\end{parts}
\end{questions}
\end{document}

Binary file not shown.

Binary file not shown.