[simulations] exercise for normal data
This commit is contained in:
parent
7ba1c83620
commit
f0f757edad
14
simulations/code/normaldata.m
Normal file
14
simulations/code/normaldata.m
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
randn(1, 3)
|
||||||
|
randn(3, 1)
|
||||||
|
randn(2, 4)
|
||||||
|
|
||||||
|
mu = 220.0; % mean and ...
|
||||||
|
sigma = 30.0; % ... standard deviation of the tigers in kg
|
||||||
|
|
||||||
|
for n = [100, 10000]
|
||||||
|
fprintf('\nn=%d:\n', n)
|
||||||
|
for i = 1:5
|
||||||
|
x = sigma*randn(n, 1) + mu; % weights of n tigers
|
||||||
|
fprintf(' m=%3.0fkg, std=%3.0fkg\n', mean(x), std(x))
|
||||||
|
end
|
||||||
|
end
|
31
simulations/code/normaldata.out
Normal file
31
simulations/code/normaldata.out
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
>> normaldata
|
||||||
|
|
||||||
|
ans =
|
||||||
|
|
||||||
|
-0.89120 1.19863 0.95487
|
||||||
|
|
||||||
|
ans =
|
||||||
|
|
||||||
|
-1.10001
|
||||||
|
0.79473
|
||||||
|
0.85979
|
||||||
|
|
||||||
|
ans =
|
||||||
|
|
||||||
|
-1.19206 0.58278 1.70286 -1.28122
|
||||||
|
-0.19966 -1.85623 0.17962 -0.19272
|
||||||
|
|
||||||
|
|
||||||
|
n=100:
|
||||||
|
m=218kg, std= 31kg
|
||||||
|
m=227kg, std= 29kg
|
||||||
|
m=224kg, std= 28kg
|
||||||
|
m=214kg, std= 26kg
|
||||||
|
m=219kg, std= 30kg
|
||||||
|
|
||||||
|
n=10000:
|
||||||
|
m=220kg, std= 30kg
|
||||||
|
m=220kg, std= 30kg
|
||||||
|
m=220kg, std= 30kg
|
||||||
|
m=220kg, std= 30kg
|
||||||
|
m=220kg, std= 30kg
|
@ -13,40 +13,58 @@ data sets. With simulated data we can also test our own analysis
|
|||||||
functions. More importantly, by means of simulations we can explore
|
functions. More importantly, by means of simulations we can explore
|
||||||
possible outcomes of our planned experiments before we even started
|
possible outcomes of our planned experiments before we even started
|
||||||
the experiment or we can explore possible results for regimes that we
|
the experiment or we can explore possible results for regimes that we
|
||||||
cannot test experimentally. How dynamical systems, like predator-prey
|
cannot test experimentally. How dynamical systems, like for example
|
||||||
interactions or the activity of neurons, evolve in time is a central
|
predator-prey interactions or the activity of neurons, evolve in time
|
||||||
application for simulations. Only with the availability of computers
|
is a central application for simulations. Computers becoming available
|
||||||
in the second half of the twentieth century was the exciting field of
|
from the second half of the twentieth century on pushed the exciting
|
||||||
nonlinear dynamical systems pushed forward. Conceptually, many kinds
|
field of nonlinear dynamical systems forward. Conceptually, many kinds
|
||||||
of simulations are very simple and are implemented in a few lines of
|
of simulations are very simple and are implemented in a few lines of
|
||||||
code.
|
code.
|
||||||
|
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
\section{Univariate data}
|
\section{Univariate data}
|
||||||
The most basic simulation is to draw random numbers from a given
|
The most basic type of simulation is to draw random numbers from a
|
||||||
distribution. This simulates repeated measurements of some quantity
|
given distribution like, for example, the normal distribution. This
|
||||||
(e.g., weight of tigers or firing rate of a neuron). That is we take
|
simulates repeated measurements of some quantity (e.g., weight of
|
||||||
samples from a statistical population. Doing so we must specify from
|
tigers or firing rate of neurons). Doing so we must specify from which
|
||||||
which probability distribution the data should originate from and what
|
probability distribution the data should originate from and what are
|
||||||
are the parameters (i.e. mean, standard deviation, ...) of that
|
the parameters (mean, standard deviation, shape parameters, etc.)
|
||||||
distribution.
|
that distribution.
|
||||||
|
|
||||||
For drawing numbers from a normal distribution we use the
|
For drawing numbers $x_i$ from a normal distribution we use the
|
||||||
\code{randn()} function. This function returns normally distributed
|
\code{randn()} function. This function returns normally distributed
|
||||||
numbers with zero mean and unit standard deviation. For changing the
|
numbers $\xi_i$ with zero mean and unit standard deviation. For
|
||||||
standard deviation we need to multiply the returned data values with
|
changing the standard deviation $\sigma$ we need to multiply the
|
||||||
the required standard deviation. For changing the mean we just add the
|
returned data values with the required standard deviation. For
|
||||||
desired mean to the random numbers.
|
changing the mean we just add the desired mean $\mu$ to the random
|
||||||
|
numbers:
|
||||||
\begin{equation}
|
\begin{equation}
|
||||||
x_i = \mu + \sigma \xi_i
|
x_i = \sigma \xi_i + \mu
|
||||||
\end{equation}
|
\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()
|
||||||
|
|
||||||
draw (and plot) random numbers
|
plot random numbers
|
||||||
|
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
\section{Static nonlinearities}
|
\section{Static nonlinearities}
|
||||||
|
|
||||||
|
Example: mechanotransduciton!
|
||||||
|
|
||||||
draw (and plot) random functions
|
draw (and plot) random functions
|
||||||
|
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
@ -55,6 +73,11 @@ draw (and plot) random functions
|
|||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
\item euler forward, odeint
|
\item euler forward, odeint
|
||||||
\item introduce derivatives which are also needed for fitting (move box from there here)
|
\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}
|
\end{itemize}
|
||||||
|
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
Reference in New Issue
Block a user