%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \chapter{Simulations} \label{simulationschapter} \exercisechapter{Simulations} The real power of computers for data analysis is the possibility to run simulations. Experimental data of almost unlimited sample sizes can be simulated in no time. This allows to explore basic concepts, like the ones we introduce in the following chapters, with well controlled data sets that are free of confounding pecularities of real data sets. With simulated data we can also test our own analysis functions. More importantly, by means of simulations we can explore possible outcomes of our planned experiments before we even started the experiment or we can explore possible results for regimes that we cannot test experimentally. How dynamical systems, like for example predator-prey interactions or the activity of neurons, evolve in time is a central application for simulations. Computers becoming available from the second half of the twentieth century on pushed the exciting field of nonlinear dynamical systems forward. Conceptually, many kinds of simulations are very simple and are implemented in a few lines of code. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Univariate data} The most basic type of simulation is to draw random numbers from a given distribution like, for example, the normal distribution. This simulates repeated measurements of some quantity (e.g., weight of tigers or firing rate of neurons). Doing so we must specify from which probability distribution the data should originate from and what are the parameters (mean, standard deviation, shape parameters, etc.) that distribution. For drawing numbers $x_i$ from a normal distribution we use the \code{randn()} function. This function returns normally distributed numbers $\xi_i$ with zero mean and unit standard deviation. For changing the standard deviation $\sigma$ we need to multiply the returned data values with the required standard deviation. For changing the mean we just add the desired mean $\mu$ to the random numbers: \begin{equation} x_i = \sigma \xi_i + \mu \end{equation} \begin{exercise}{normaldata.m}{normaldata.out} First, read the documentation of the \varcode{randn()} function and check its output for a some (small) input arguments. Write a little script that generates $n=100$ normally distributed data simulating the weight of Bengal tiger males with mean 220\,kg and standard deviation 30\,kg. Check the actual mean and standard deviation of the generated data. Do this, let's say, five times using a for-loop. Then increase $n$ to 10\,000 and run the code again. It is so simple to measure the weight of 10\,000 tigers for getting a really good estimate of their mean weight, isn't it? \end{exercise} Other pdfs (rand(), gamma). randi() plot random numbers %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Static nonlinearities} Example: mechanotransduciton! draw (and plot) random functions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Dynamical systems} \begin{itemize} \item euler forward, odeint \item introduce derivatives which are also needed for fitting (move box from there here) \item Passive membrane \item Add passive membrane to mechanotransduction! \item Integrate and fire \item Fitzugh-Nagumo \item Two coupled neurons? Predator-prey? \end{itemize} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Summary} with outook to other simulations (cellular automata, monte carlo, etc.) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \printsolutions