diff --git a/pointprocesses/lecture/pointprocesses.tex b/pointprocesses/lecture/pointprocesses.tex index d25cf08..5849a9a 100644 --- a/pointprocesses/lecture/pointprocesses.tex +++ b/pointprocesses/lecture/pointprocesses.tex @@ -1,6 +1,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \chapter{Spiketrain analysis} +\label{pointprocesseschapter} \exercisechapter{Spiketrain analysis} \entermde[action potential]{Aktionspotential}{Action potentials} diff --git a/simulations/code/exprandom.m b/simulations/code/exprandom.m new file mode 100644 index 0000000..6e20a9b --- /dev/null +++ b/simulations/code/exprandom.m @@ -0,0 +1,8 @@ +n = 10000; +lambda = 50.0; % event rate +t = exprnd(1.0/lambda, n, 1); % exponentially distributed random numbers +m = mean(t); % mean time interval +s = std(t); % corresponding standard deviation +fprintf('Generated n=%d exponentially distributed random time intervals\n', n); +fprintf(' with rate=%.0fHz (-> mean=%.3fs, std=%.3fs)\n', lambda, 1.0/lambda, 1.0/lambda); +fprintf('Measured mean=%.3fs, std=%.3fs\n', m, s); diff --git a/simulations/code/exprandom.out b/simulations/code/exprandom.out new file mode 100644 index 0000000..2c91625 --- /dev/null +++ b/simulations/code/exprandom.out @@ -0,0 +1,3 @@ +Generated n=10000 exponentially distributed random time intervals + with rate=50Hz (-> mean=0.020s, std=0.020s) +Measured mean=0.020s, std=0.020s diff --git a/simulations/code/probability.m b/simulations/code/probability.m new file mode 100644 index 0000000..c7da8d4 --- /dev/null +++ b/simulations/code/probability.m @@ -0,0 +1,6 @@ +n = 20; % number of coin flips +P = 0.6; % probability of head +u = rand(n, 1); % n random numbers between 0 and 1 +heads = u < P; % true if head showed up +nheads = sum(heads); % number of heads +fprintf('Of %d coin flips, %d heads showed up.\n', n, nheads); diff --git a/simulations/code/probability.out b/simulations/code/probability.out new file mode 100644 index 0000000..8ae62ee --- /dev/null +++ b/simulations/code/probability.out @@ -0,0 +1 @@ +Of 20 coin flips, 12 heads showed up. diff --git a/simulations/lecture/simulations.tex b/simulations/lecture/simulations.tex index 0c1d3d1..15cb87f 100644 --- a/simulations/lecture/simulations.tex +++ b/simulations/lecture/simulations.tex @@ -38,7 +38,8 @@ generator!pseudo]{pseudo random number generators}. In rare cases this periodicity can induce problems in simulations whenever more random numbers than the period of the random number generator are used. Luckily, nowadays the periods of random nunmber generators are -very large, $2^{64}$, $2^{128}$, or even larger. +very large. Periods are at least in the range of $2^{64}$, that is +about $10^{18}$, or even larger. The pseudo randomness of numerical random number generators also has an advantage. They allow to repeat exactly the same sequence of @@ -124,15 +125,66 @@ mean we just add the desired mean $\mu$ to the random numbers: \end{exercise} \subsection{Other probability densities} -\code{rand()} -gamma +We can draw random numbers not only from normal +distributions. Functions are provided that let you draw random numbers +of almost any probability distribution. They differ in their shape and +in the number of parameters they have. Most probability distributions +are parameterized by a location parameter that usually coincides with +their mean, and a scale parameter that often coincides with their +standard deviation. Some distributions have additional shape +parameters. + +For example, the time intervals $t$ between randomly generated action +potentials (a so called Poisson spike train, see +chapter~\ref{pointprocesseschapter}) are exponentially distributed --- +as are the intervals between state transitions of ion channels, or the +intervals between radioactive decays. The exponential distribution is +only defined for positive time intervals: +\begin{equation} + \label{expdistribution} + p_{exp}(t) = \lambda e^{-\lambda t} \; , \quad t \ge 0, \; \lambda > 0 +\end{equation} +The exponential distribution is parameterized by a single rate +parameter $\lambda$ measured in Hertz. It defines how often per time +unit the event happens. Both the mean interval between the events and +the corresponding standard deviation equal the inverse rate. + +\begin{exercise}{exprandom.m}{exprandom.out} + Draw $n=10\,000$ random time intervals from an exponential + distribution with rate $\lambda=50$\,Hz. Calculate the mean and the + standard deviation of the random numbers and compare them with the + expected values. +\end{exercise} + +The gamma distribution (\code{gamrnd()}) phenomenologically describes +various types of interspike interval dsitributions +(chapter~\ref{pointprocesseschapter}). scale and shape. exercise. + + \code{rand()} between xmin +and xmax. + +\subsection{Simulating probabilities} +Simulating events that happen with some probability $P$ is also +possible. That could be the probability of head showing up when +flipping a coin, getting an action potential within some time, a ion +channel to open, ... For this draw a random number $u_i$ from a +uniform distribution between zero and one (\code{rand()}). If the +random number is lower than $P$, the event happens, if it is larger +the event does not occur. + +\begin{exercise}{probability.m}{probability.out} + Let's flip a coin 20 times. The coin is biased and shows head with a + probability of $P=0.6$. Count the number of heads. +\end{exercise} \subsection{Random integers} \code{randi()} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\section{Bivariate data and static nonlinearities} +\section{Bivariate data} + +\subsection{Static nonlinearities} \begin{figure}[t] \includegraphics[width=1\textwidth]{staticnonlinearity} @@ -147,7 +199,8 @@ gamma Example: mechanotransduciton! -draw (and plot) random functions (in statistics chapter?) +draw (and plot) random functions. + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Dynamical systems}