From 5e5ea9965ca4239898d73cbbaaa44c587e58cb1c Mon Sep 17 00:00:00 2001 From: Jan Benda Date: Wed, 18 Dec 2019 10:19:33 +0100 Subject: [PATCH] [simulations] improved univariate data exercise --- simulations/code/normaldata.m | 8 +++++++- simulations/lecture/simulations.tex | 22 +++++++++++++++------- statistics/lecture/statistics.tex | 1 + 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/simulations/code/normaldata.m b/simulations/code/normaldata.m index d30db7c..ad395f7 100644 --- a/simulations/code/normaldata.m +++ b/simulations/code/normaldata.m @@ -1,10 +1,11 @@ +% getting familiar with the randn() function: randn(1, 3) randn(3, 1) randn(2, 4) +% simulate tiger weights: 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 @@ -12,3 +13,8 @@ for n = [100, 10000] fprintf(' m=%3.0fkg, std=%3.0fkg\n', mean(x), std(x)) end end + +% plot the data: +plot(x(1:1000), 'o') +xlabel('Index') +ylabel('Weight [kg]') diff --git a/simulations/lecture/simulations.tex b/simulations/lecture/simulations.tex index 762bcf1..e0803cc 100644 --- a/simulations/lecture/simulations.tex +++ b/simulations/lecture/simulations.tex @@ -29,8 +29,12 @@ 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. +that distribution. How to illuastrate and quantify univariate data, no +matter whether they have been actually measured or whether they are +simulated as described in the following, is described in +chapter~\ref{descriptivestatisticschapter}. +\subsection{Normally distributed data} 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 @@ -44,28 +48,32 @@ numbers: \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 + check its output for 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? + really good estimate of their mean weight, isn't it? Finally plot + from the last generated data set of tiger weights the first 1000 + values as a function of their index. \end{exercise} -Other pdfs (rand(), gamma). +\subsection{Uniformly distributed data} +\code{rand()} -randi() +\subsection{Other distributions} -plot random numbers +\subsection{Random integers} +\code{randi()} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Static nonlinearities} Example: mechanotransduciton! -draw (and plot) random functions +draw (and plot) random functions (in statistics chapter?) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Dynamical systems} diff --git a/statistics/lecture/statistics.tex b/statistics/lecture/statistics.tex index 28b5443..59a3c0f 100644 --- a/statistics/lecture/statistics.tex +++ b/statistics/lecture/statistics.tex @@ -1,6 +1,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \chapter{Descriptive statistics} +\label{descriptivestatisticschapter} \exercisechapter{Descriptive statistics} Descriptive statistics characterizes data sets by means of a few measures.