[simulations] added exponential distribution
This commit is contained in:
parent
5e9ad55d1c
commit
a50cc4ff7b
@ -1,6 +1,7 @@
|
|||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
\chapter{Spiketrain analysis}
|
\chapter{Spiketrain analysis}
|
||||||
|
\label{pointprocesseschapter}
|
||||||
\exercisechapter{Spiketrain analysis}
|
\exercisechapter{Spiketrain analysis}
|
||||||
|
|
||||||
\entermde[action potential]{Aktionspotential}{Action potentials}
|
\entermde[action potential]{Aktionspotential}{Action potentials}
|
||||||
|
8
simulations/code/exprandom.m
Normal file
8
simulations/code/exprandom.m
Normal file
@ -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);
|
3
simulations/code/exprandom.out
Normal file
3
simulations/code/exprandom.out
Normal file
@ -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
|
6
simulations/code/probability.m
Normal file
6
simulations/code/probability.m
Normal file
@ -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);
|
1
simulations/code/probability.out
Normal file
1
simulations/code/probability.out
Normal file
@ -0,0 +1 @@
|
|||||||
|
Of 20 coin flips, 12 heads showed up.
|
@ -38,7 +38,8 @@ generator!pseudo]{pseudo random number generators}. In rare cases this
|
|||||||
periodicity can induce problems in simulations whenever more random
|
periodicity can induce problems in simulations whenever more random
|
||||||
numbers than the period of the random number generator are
|
numbers than the period of the random number generator are
|
||||||
used. Luckily, nowadays the periods of random nunmber generators 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
|
The pseudo randomness of numerical random number generators also has
|
||||||
an advantage. They allow to repeat exactly the same sequence of
|
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}
|
\end{exercise}
|
||||||
|
|
||||||
\subsection{Other probability densities}
|
\subsection{Other probability densities}
|
||||||
\code{rand()}
|
We can draw random numbers not only from normal
|
||||||
gamma
|
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}
|
\subsection{Random integers}
|
||||||
\code{randi()}
|
\code{randi()}
|
||||||
|
|
||||||
|
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
\section{Bivariate data and static nonlinearities}
|
\section{Bivariate data}
|
||||||
|
|
||||||
|
\subsection{Static nonlinearities}
|
||||||
|
|
||||||
\begin{figure}[t]
|
\begin{figure}[t]
|
||||||
\includegraphics[width=1\textwidth]{staticnonlinearity}
|
\includegraphics[width=1\textwidth]{staticnonlinearity}
|
||||||
@ -147,7 +199,8 @@ gamma
|
|||||||
|
|
||||||
Example: mechanotransduciton!
|
Example: mechanotransduciton!
|
||||||
|
|
||||||
draw (and plot) random functions (in statistics chapter?)
|
draw (and plot) random functions.
|
||||||
|
|
||||||
|
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
\section{Dynamical systems}
|
\section{Dynamical systems}
|
||||||
|
Reference in New Issue
Block a user