Merge branch 'master' of raven.am28.uni-tuebingen.de:scientificComputing

This commit is contained in:
Jan Grewe 2014-10-12 22:47:24 +02:00
commit c4bc75b8f5
13 changed files with 455 additions and 129 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

0
statistics/figs/feeding.jpg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 201 KiB

After

Width:  |  Height:  |  Size: 201 KiB

BIN
statistics/figs/histogram.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
statistics/figs/histogrambad.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

BIN
statistics/figs/histogrambad2.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

0
statistics/figs/nacho-trainer.jpg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 132 KiB

After

Width:  |  Height:  |  Size: 132 KiB

BIN
statistics/figs/nobelbad.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

0
statistics/figs/nominaldataplot.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

0
statistics/figs/nominaldataplot2.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

0
statistics/figs/soccer.jpg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 56 KiB

View File

@ -4,7 +4,6 @@
\usepackage{pgf} \usepackage{pgf}
%\usepackage{pgf,pgfarrows,pgfnodes,pgfautomata,pgfheaps,pgfshade} %\usepackage{pgf,pgfarrows,pgfnodes,pgfautomata,pgfheaps,pgfshade}
%\usepackage{multimedia} %\usepackage{multimedia}
\usepackage[ngerman]{babel}
\usepackage[latin1]{inputenc} \usepackage[latin1]{inputenc}
\usepackage{amsmath} \usepackage{amsmath}
\usepackage{bm} \usepackage{bm}
@ -86,13 +85,13 @@ Bernstein Center T\"ubingen}
\end{frame} \end{frame}
\begin{frame} \begin{frame}
\frametitle{Plan} \frametitle{plan}
\setcounter{tocdepth}{1} \setcounter{tocdepth}{1}
\tableofcontents \tableofcontents
\end{frame} \end{frame}
\begin{frame} \begin{frame}
\frametitle{Information \"uber Statistik} \frametitle{information}
\begin{itemize} \begin{itemize}
\item Samuels, M. L., Wittmer, J. A., \& Schaffner, \item Samuels, M. L., Wittmer, J. A., \& Schaffner,
A. A. (2010). Statistics for the Life Sciences (4th ed., A. A. (2010). Statistics for the Life Sciences (4th ed.,
@ -114,41 +113,41 @@ Bernstein Center T\"ubingen}
% PCA % PCA
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section[Präludium]{Präludium} \section[Prelude]{Prelude}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ---------------------------------------------------------- % ----------------------------------------------------------
\begin{frame} \begin{frame}
\frametitle{Meine Erwartungen an Masterstudenten} \frametitle{my expectations to this course}
\begin{itemize} \begin{itemize}
\item Interesse und Partizipation \item interest and participation
\item Motivation Konzepte zu verstehen und zu hinterfragen \item motivation to understand and question concepts
\item einen hohen wissenschaftlichen Qualitätsstandard \item high scientific standard
\item intellektuelle Redlichkeit \item intellectual honesty
\item ehrliche Kooperation \item sincere cooperation
\end{itemize} \end{itemize}
\end{frame} \end{frame}
% ---------------------------------------------------------- % ----------------------------------------------------------
\begin{frame} \begin{frame}
\frametitle{diese Woche wird ...} \frametitle{this week will be ...}
\only<1>{ \only<1>{
\framesubtitle{... kein \sout{Spaß} Zuckerschlecken} \framesubtitle{... no \sout{fun} piece of cake}
\begin{center} \begin{center}
\includegraphics[height=0.7\textheight]{figs/feeding.jpg} \includegraphics[height=0.7\textheight]{figs/feeding.jpg}
\end{center} \end{center}
} }
\only<2>{ \only<2>{
\framesubtitle{... kein \sout{Spaß} Zuckerschlecken} \framesubtitle{... no \sout{fun} piece of cake}
\begin{center} \begin{center}
\includegraphics[height=0.7\textheight]{figs/nacho-trainer.jpg} \includegraphics[height=0.7\textheight]{figs/nacho-trainer.jpg}
\end{center} \end{center}
} }
\only<3>{ \only<3>{
\framesubtitle{... keine Vorlesung (Bitte!)} \framesubtitle{... no lecture (please!)}
\begin{center} \begin{center}
\includegraphics[height=0.7\textheight]{figs/soccer.jpg} \includegraphics[height=0.7\textheight]{figs/soccer.jpg}
\end{center} \end{center}
@ -158,138 +157,131 @@ Bernstein Center T\"ubingen}
% ---------------------------------------------------------- % ----------------------------------------------------------
\begin{frame} \begin{frame}
\frametitle{Was Ihr diese Woche lernen solltet} \frametitle{What you should learn this week}
\begin{itemize} \begin{itemize}
\item Eigenschaften guter Plots \item What makes good plots?
\item Was ist deskriptive/ inferentielle Statistik? \item What is descriptive/inferential statistics?
\item die generelle Struktur statistischer Tests \item What is the general structure of a statistical test?
\item Was ist/bedeutet ein p-Wert? \item What does a p-value mean?
\item Wie bastele ich mir meinen eigenen Test? \item How can I build my own tests?
\item Wie groß muß mein $n$ sein? \item How large should my $n$ be?
\item Principal Component Analysis (PCA) \item What is {\em maximum likelihood} and why is it important?
\end{itemize} \end{itemize}
\end{frame} \end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section[deskriptive Statistik, Fehlerbalken \& Plots]{Day 1 -- Deskriptive \section[descriptive statistics, errorbars, and plots]{Day 1 -- descriptive statistics, errorbars, and plots}
Statistik, Fehlerbalken und Plots}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Arten von Daten} \subsection{types of data}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame} \begin{frame}
\frametitle{Datenskalen} \frametitle{data scales}
\framesubtitle{Welche Datentypen gibt es in der Statistik?} \framesubtitle{What data types are distinguished in statistics?}
\Large \Large
{\bf Warum sind Datentypen wichtig?} {\bf Why are data types important?}
\pause \pause
\begin{itemize} \begin{itemize}
\item Auswahl passender Statistiken \item selection of statistics
\item Auswahl angemessener Plots \item selection of plots
\item Auswahl von korrekten Tests \item selection of correct tests
\end{itemize} \end{itemize}
\end{frame} \end{frame}
%------------------------------------------------------------- %-------------------------------------------------------------
\begin{frame} \begin{frame}
\frametitle{Datenskalen} \frametitle{data scales}
\framesubtitle{Nominalskala (engl. ,,categorial'')} \framesubtitle{nominal/categorial scale}
\begin{itemize} \begin{itemize}
\item Eigenschaften wie Zelltyp, Versuchsgruppe \item properties like cell type, experimental group (i.e. treatment
\item jede Beobachtung wird eine bestimmten Klasse (Kategorie) 1, treatment 2, control)
zugeordnet \item each observation/sample is put into one category
\item Die Klassen besitzen keine sinnvolle Ordnung \item there is no reasonable order among the categories
\item Beispiel: [Zapfen, Stäbchen] vs. [Stäbchen, Zapfen] \item example: [rods, cones] vs. [cones, rods]
\end{itemize} \end{itemize}
\end{frame} \end{frame}
%------------------------------------------------------------- %-------------------------------------------------------------
\begin{frame} \begin{frame}
\frametitle{Datenskalen} \frametitle{data scales}
\framesubtitle{Ordinalskala (engl. ,,ordinal'')} \framesubtitle{ordinal scale}
\begin{itemize} \begin{itemize}
\item Wie Nominalskala, nur ist sinnvolles Ordnen m\"oglich \item like nominal scale, but there is an order
\item {\bf aber:} Unterschiede zwischen den Werten bzw. Klassen \item {\bf but:} there is no reasonable measure of {\em distance}
nicht vergleichbar (keine Abst\"ande) between the classes
\item Beispiel: Platzierungen, G\"uteklassen, Ratingskalen \item examples: ranks, ratings
\end{itemize} \end{itemize}
\end{frame} \end{frame}
%------------------------------------------------------------- %-------------------------------------------------------------
\begin{frame} \begin{frame}
\frametitle{Datenskalen} \frametitle{data scales}
\framesubtitle{Intervallskala (engl. ,,interval'')} \framesubtitle{interval scale}
\begin{itemize} \begin{itemize}
\item quantitative/metrische Werte \item quantitative/metric values
\item Abst\"ande zwischen Werten sind sinnvoll, aber es gibt keine \item reasonable measure of distance between values but no absolute zero
absoluten Nullpunkt \item examples: temperature in $^\circ$C
\item Beispiel: physikalische Gr\"o{\ss}en wie Temperatur in Grad Celsius
\end{itemize} \end{itemize}
\end{frame} \end{frame}
%------------------------------------------------------------- %-------------------------------------------------------------
\begin{frame} \begin{frame}
\frametitle{Datenskalen} \frametitle{data scales}
\framesubtitle{Absolut- oder Verh\"altnisskala (engl. ,,ratio)} \framesubtitle{absolut/ratio scale}
\begin{itemize} \begin{itemize}
\item wie Intervallskala, aber mit absolutem Nullpunkt \item like interval scale but with absolute zero
\item Beispiel: Temperatur in Kelvin, Einkommen \item example: temperature in $^\circ$K
\end{itemize} \end{itemize}
\pause \pause
\begin{emphasize}{Verh\"altnis der Skalen} \begin{emphasize}{relationsships between scales}
\begin{itemize} \begin{itemize}
\item Skalen besitzen aufsteigenden Informationsgehalt von \item scales exhibit increasing information content from nominal
Nominal- zu Absolutskala to absolute
\item Konvertierung ,,abw\"arts'' immer m\"oglich \item conversion ,,downwards'' always possible
\end{itemize} \end{itemize}
\end{emphasize} \end{emphasize}
\end{frame} \end{frame}
%------------------------------------------------------------- %-------------------------------------------------------------
\begin{frame} \begin{frame}
\frametitle{Beispiele aus Neuro-/Kognitionswissenschaften} \frametitle{examples from neuroscience and psychology}
\begin{itemize} \begin{itemize}
\item {\bf Nominalskala:}\pause \item {\bf nominal:}\pause
\begin{itemize} \begin{itemize}
\item Versuchsgruppenzugeh\"origkeit \item treatment group
\item Stimulusklasse \item stimulus class
\item Zelltyp \item cell type
\end{itemize} \end{itemize}
\item {\bf Ordinalskala:} \pause \item {\bf ordinal:} \pause
\begin{itemize} \begin{itemize}
\item Ratings \item ratings
\item Krankheitsstadien \item clinical stages of a disease
\item Zust\"ande eines Ionenkanals \item states of an ion channel
\end{itemize} \end{itemize}
\item {\bf Absolut-/Ratioskala:}\pause \item {\bf Absolut-/Ratioskala:}\pause
\begin{itemize} \begin{itemize}
\item Feuerrate \item firing rate
\item Membranpotential \item membrane potential
\item Ionenkonzentration \item ion concentration
\end{itemize} \end{itemize}
\end{itemize} \end{itemize}
\end{frame} \end{frame}
%------------------------------------------------------------- %-------------------------------------------------------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Statistiken} \subsection{statistics}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%------------------------------------------------------------- %-------------------------------------------------------------
\begin{frame} \begin{frame}
\frametitle{Was ist eine (Test)-Statistik} \frametitle{What is "a statistic"?}
\begin{definition}{Teststatistik, Pr\"ufwert} \begin{definition}{statistic}
\begin{itemize} A statistic (singular) is a single measure of some attribute of a
\item Als {\em Teststatistik} bezeichnet man in der mathematischen sample (e.g., its arithmetic mean value). It is calculated by
Statistik eine Stichprobenfunktion die einer Stichprobe einen applying a function (statistical algorithm) to the values of the
Wert zuordnet (z.B. Mittelwert, Median, Standardabweichung, items of the sample, which are known together as a set of data.
...).
\source{http://en.wikipedia.org/wiki/Statistic}
\item Als {\em Pr\"ufwert} wird die Realisation einer Teststatistik
anhand einer Stichprobe bezeichnet.
\source{http://de.wikipedia.org/wiki/Teststatistik}
\end{itemize}
\end{definition} \end{definition}
\end{frame} \end{frame}
@ -297,50 +289,51 @@ Bernstein Center T\"ubingen}
\begin{frame} \begin{frame}
\frametitle{Beispiele f\"ur Teststatistiken} \frametitle{Beispiele f\"ur Teststatistiken}
\begin{itemize} \begin{itemize}
\item {\bf Nominalskala:}\pause \item {\bf nominal:}\pause
\begin{itemize} \begin{itemize}
\item Anzahl \item count
\item relative H\"aufigkeit \item relative frequency/proportion
\end{itemize} \end{itemize}
\item {\bf Ordinalskala:} \pause \item {\bf ordinal:} \pause
\begin{itemize} \begin{itemize}
\item Median \item median
\item Perzentilen \item quantile/percentile
\item Rangkorrelationskoeffizient \item rank correlation
\end{itemize} \end{itemize}
\item {\bf Absolut-/Ratioskala:}\pause \item {\bf absolute/ratio:}\pause
\begin{itemize} \begin{itemize}
\item Mittelwert \item mean
\item Varianz/ Standardabweichung \item variance/ standard deviation
\item Pearson Korrelationskoeffizient \item Pearson correlation
\end{itemize} \end{itemize}
\end{itemize} \end{itemize}
\end{frame} \end{frame}
%------------------------------------------------------------- %-------------------------------------------------------------
\begin{frame} \begin{frame}
\frametitle{\"Ubung} \frametitle{exercise}
\begin{task}{Spearman Rangkorrelationskoeffizient} \begin{task}{Spearman rank correlation}
\begin{enumerate} \begin{enumerate}
\item Benutze {\tt randi} um zwei 100-dimensionale Vektoren {\tt x,y} mit \item Use {\tt randi} to generate two 100-dimensional vectors
Zufalls-Integern zwischen $0$ und $10$ zu berechnen. {\tt x,y} of random integers between $0$ and $10$.
\item Finde heraus wie man in Matlab den Spearman \item Find out how to compute the Spearman
Rangkorrelationskoeffizient $$\rho = 1- {\frac {6 \sum rank correlation $$\rho = 1- {\frac {6 \sum
d_i^2}{n(n^2 - 1)}}$$ berechnet. $d_i = x_i - y_i$ ist die d_i^2}{n(n^2 - 1)}}$$ with Matlab. $d_i = x_i - y_i$ is the
Differenz im Rang der Datenpunkte. difference in the rank between the single data points.
\item Berechne $\rho$ zwischen $x$ und $y$, zwischen $x$ und \item Compute $\rho$ between $x$ and $y$, between $x$ and
$y^2$, zwischen $\log(x+1)$ und $y^2$. Berechne auch den $y^2$, between $\log(x+1)$ and $y^2$.
\"ublichen (Pearson) Korrelationskoeffizient zwischen diesen \item Compute the "standard" (Pearson) correlation coefficient
Werten. Was kann man beobachten und warum macht das Sinn? between these values.
\item What can you observe and why does it make sense?
\end{enumerate} \end{enumerate}
\end{task} \end{task}
\end{frame} \end{frame}
%------------------------------------------------------------- %-------------------------------------------------------------
\begin{frame}[fragile] \begin{frame}[fragile]
\frametitle{\"Ubung - L\"osung} \frametitle{solution}
\begin{solution}{Spearman Rangkorrelationskoeffizient} \begin{solution}{Spearman rank correlation }
\scriptsize \scriptsize
\begin{lstlisting} \begin{lstlisting}
>>> x = randi(10, 100, 1); >>> x = randi(10, 100, 1);
@ -358,55 +351,185 @@ ans =
ans = ans =
0.0551 0.0551
\end{lstlisting} \end{lstlisting}
Der Rangkorrelationskoeffizient \"andert sich nicht bei monotoner The rank correlation does not change under a monotone transformation
Transformation der Daten. Daher ist er f\"ur ordinale Daten of the data. Therefore, it can be used for ordinal data. The Pearson
geeignet. Der Pearson Korrelationskoeffizient ist es nicht. correlation coefficient does not have that property.
\end{solution} \end{solution}
\end{frame} \end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Beschreibung und Darstellung von Daten} \section{description of data and plotting}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Nominalskala} \subsection{nominal scale}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%------------------------------------------------------------- %-------------------------------------------------------------
\begin{frame}[fragile] \begin{frame}[fragile]
\frametitle{Darstellung nominaler Daten} \frametitle{}
\framesubtitle{Bar-Plot f\"ur Anzahl/ rel. H\"aufigkeit} \begin{center}
\Huge What makes a good plot?
\end{center}
\end{frame}
%-------------------------------------------------------------
\begin{frame}[fragile]
\frametitle{features of a good plot}
A good plot
\begin{itemize}
\item helps the reader to clearly understand your point.\pause
\item is not misleading and let's the reader judge the information
on her own (different y-axis/length scales in two related plots,
"squeezing" via log-plots). \pause
\item contains information about the data (a comic might be
illustrative, but does not contain information about the
data).\pause
\item adheres to the principle of {\em ink minimization}.
\end{itemize}
\end{frame}
%-------------------------------------------------------------
\begin{frame}[fragile]
\frametitle{features of a good plot}
\framesubtitle{design/organization}
\begin{itemize}
\item Is the display consistent with the model or hypothesis
being tested?\pause
\item Are there "empty dimensions" in the display that could be
removed (A 3D pie chart for 2D categorical data, extraneous colors
that do not encode meaningful information)?\pause
\item Does the display provide an honest and transparent portrayal
of the data (hiding, smoothing, modifying data points should be
avoided or explicitly mentioned)?
\end{itemize}
\mycite{Allen et al. 2012, Neuron}
\end{frame}
%-------------------------------------------------------------
\begin{frame}[fragile]
\frametitle{features of a good plot}
\framesubtitle{axes}
\begin{itemize}
\item Are axes scales defined as linear, log, or radial?\pause
\item Does each axis label describe the variable and its units (use
"a.u." for arbitrary units)?\pause
\item Are axes limits appropriate for the data (The graphic should
not be bounded at zero if the data can take on both positive and
negative values.)?\pause
\item Is the aspect ratio appropriate for the data (When x and y
axes contrast the same variable under different conditions the
graphic should be square.)?
\end{itemize}
\mycite{Allen et al. 2012, Neuron}
\end{frame}
%-------------------------------------------------------------
\begin{frame}[fragile]
\frametitle{features of a good plot}
\framesubtitle{color mapping}
\begin{itemize}
\item Is a color bar provided?\pause
\item Is the color map sensible for the data type (does the data
extend to both $\pm$, does it live in an interval, is it
circular)?\pause
\item Are contrasting colors consistent with a natural interpretation?
\item Can features be discriminated when printed in grayscale?
\item Has red/green contrast been avoided to accommodate common
forms of colorblindness?
\end{itemize}
\mycite{Allen et al. 2012, Neuron}
\end{frame}
%-------------------------------------------------------------
\begin{frame}[fragile]
\frametitle{features of a good plot}
\framesubtitle{uncertainty}
\begin{itemize}
\item Does the display indicate the uncertainty of estimated parameters?\pause
\item Is the type of error surface appropriate for the data?
\begin{itemize}
\item Use standard deviations to describe variability in the population.\pause
\item Use standard errors or confidence intervals to make inferences
about parameters estimated from a sample.\pause
\item Parametric confidence intervals should only be used if data
meet the assumptions of the underlying model.\pause
\end{itemize}
\item Are the units of uncertainty defined (is it standard error, is
it $95\%$ confidence interval)?
\end{itemize}
\mycite{Allen et al. 2012, Neuron}
\end{frame}
%-------------------------------------------------------------
\begin{frame}[fragile]
\frametitle{features of a good plot}
\framesubtitle{annotation}
\begin{itemize}
\item Are all symbols defined, preferably by directly labeling objects?\pause
\item Is the directionality of a contrast between conditions obvious?\pause
\item Is the number of samples or independent experiments indicated?\pause
\item Are statistical procedures and criteria for significance described?\pause
\item Are uncommon abbreviations avoided or clearly defined?\pause
\item Are abbreviations consistent with those used in the text?
\end{itemize}
\mycite{Allen et al. 2012, Neuron}
\end{frame}
%-------------------------------------------------------------
\begin{frame}[fragile]
\frametitle{suboptimal example}
\begin{center}
\includegraphics[width=.5\linewidth]{figs/nobelbad}
\end{center}
\mycite{Hafting et al. 2005, nature}
\end{frame}
%-------------------------------------------------------------
\begin{frame}[fragile]
\frametitle{different axes}
\end{frame}
%-------------------------------------------------------------
\begin{frame}
\frametitle{Bad bar plot}
\begin{center}
\includegraphics[width=.8\linewidth]{figs/badbarplot}
\end{center}
\source{www.enfovis.com}
\end{frame}
%-------------------------------------------------------------
\begin{frame}[fragile]
\frametitle{plotting nominal data}
\framesubtitle{bar plot for count and relative frequency}
\begin{center} \begin{center}
\includegraphics[width=.8\linewidth]{figs/nominaldataplot} \includegraphics[width=.8\linewidth]{figs/nominaldataplot}
\end{center} \end{center}
\end{frame} \end{frame}
%------------------------------------------------------------- %-------------------------------------------------------------
\begin{frame}[fragile] \begin{frame}[fragile]
\frametitle{Darstellung nominaler Daten} \frametitle{plotting nominal data}
\framesubtitle{Bar-Plot f\"ur Anzahl/ rel. H\"aufigkeit} \framesubtitle{bar plot for count and relative frequency}
\scriptsize \scriptsize
\begin{lstlisting} \begin{lstlisting}
% eigentlicher Plot % plot
bar([1,2], [50, 90], 'facecolor', 'k') bar([1,2], [50, 90], 'facecolor', 'k')
% Achsenbeschriftung % labels axes
ylabel('cell count') ylabel('cell count')
xlabel('cell type') xlabel('cell type')
% Kosmetik % cosmetics
xlim([0.5,2.5]) xlim([0.5,2.5])
ylim([0, 100]) ylim([0, 100])
box('off') box('off')
set(gca,'XTick',1:2,'XTickLabel',{'pyramidal','interneuron'},'FontSize',20) set(gca,'XTick',1:2,'XTickLabel',{'pyramidal','interneuron'},'FontSize',20)
% Settings fuers Abspeichern % settings for saving the figure
set(gcf, 'PaperUnits', 'centimeters'); set(gcf, 'PaperUnits', 'centimeters');
set(gcf, 'PaperSize', [11.7 9.0]); set(gcf, 'PaperSize', [11.7 9.0]);
set(gcf, 'PaperPosition',[0.0 0.0 11.7 9.0]); set(gcf, 'PaperPosition',[0.0 0.0 11.7 9.0]);
\end{lstlisting} \end{lstlisting}
\end{frame} \end{frame}
%------------------------------------------------------------- %----------------------------------------------------------
\begin{frame}[fragile] \begin{frame}[fragile]
\frametitle{Darstellung nominaler Daten} \frametitle{plotting nominal data}
\framesubtitle{Pie-Chart f\"ur Anzahl/ rel. H\"aufigkeit} \framesubtitle{pie chart for count and relative frequency}
\begin{center} \begin{center}
\includegraphics[width=.8\linewidth]{figs/nominaldataplot2} \includegraphics[width=.8\linewidth]{figs/nominaldataplot2}
\end{center} \end{center}
@ -414,15 +537,15 @@ set(gcf, 'PaperPosition',[0.0 0.0 11.7 9.0]);
%------------------------------------------------------------- %-------------------------------------------------------------
\begin{frame}[fragile] \begin{frame}[fragile]
\frametitle{Darstellung nominaler Daten} \frametitle{Darstellung nominaler Daten}
\framesubtitle{\"Ubung} \framesubtitle{exercise}
\begin{task}{Pie-Chart} \begin{task}{pie chart}
Plotte dieselben Daten ($n_{py}=50$, $n_{in}=90$) als Pie-Chart in Matlab. Plot the same data ($n_{py}=50$, $n_{in}=90$) as a pie chart in Matlab.
\end{task} \end{task}
\end{frame} \end{frame}
%------------------------------------------------------------- %-------------------------------------------------------------
\begin{frame}[fragile] \begin{frame}[fragile]
\frametitle{Darstellung nominaler Daten} \frametitle{Darstellung nominaler Daten}
\framesubtitle{Pie-Chart f\"ur Anzahl/ rel. H\"aufigkeit} \framesubtitle{pie chart for relative frequency}
\scriptsize \scriptsize
\begin{lstlisting} \begin{lstlisting}
data = [50, 90]; data = [50, 90];
@ -443,6 +566,66 @@ set(gcf, 'PaperPosition',[0.0 0.0 11.7 9.0]);
\end{lstlisting} \end{lstlisting}
\end{frame} \end{frame}
%-------------------------------------------------------------
\begin{frame}[fragile]
\frametitle{plotting interval/ratio/absolute data}
\framesubtitle{histogram}
\begin{center}
\includegraphics[width=.8\linewidth]{figs/histogram}
\end{center}
\end{frame}
%-------------------------------------------------------------
\begin{frame}[fragile]
\frametitle{plotting interval/ratio/absolute data}
\framesubtitle{bad choice of bins}
\begin{center}
\includegraphics[width=.4\linewidth]{figs/histogrambad}
\includegraphics[width=.4\linewidth]{figs/histogrambad2}
\end{center}
\begin{summary}{Rule of thumb}
Choose the bins $b\approx n/20$.
\end{summary}
\end{frame}
%-------------------------------------------------------------
\begin{frame}[fragile]
\frametitle{plotting interval/ratio/absolute data}
\framesubtitle{how to do in Matlab}
\scriptsize
\begin{lstlisting}
x = randn(2000,1); % generate Gaussian data
hist(x, 50); % generate histogram
% set facecolor to gray
h = findobj(gca, 'Type','patch');
set(h(1), 'FaceColor',[.2,.2,.2], 'EdgeColor','w', 'linewidth',2)
% plot a white grid over it
h = gridxy([],get(gca,'ytick'),'color','w','linewidth',2)
uistack(h, 'top')
% cosmetics
box('off');
xlabel('Data')
ylabel('Count')
\end{lstlisting}
\end{frame}
%-------------------------------------------------------------
\begin{frame}[fragile]
\frametitle{plotting interval/ratio/absolute data}
\framesubtitle{other ways}
There are other ways to plot a sample $x_1, ..., x_n$ of
interval/ratio/absolute scale data. E.g.
\begin{itemize}
\item box plot
\item bar plot
\item smoothed histogram
\item ...
\end{itemize}
We will look at them while plotting mixed data in the following.
\end{frame}
\end{document} \end{document}

127
statistics/matlab/gridxy.m Normal file
View File

@ -0,0 +1,127 @@
function hh = gridxy(x,varargin)
% GRIDXY - Plot grid lines
% GRIDXY(X) plots vertical grid lines at the positions specified
% by X. GRIDXY(X,Y) also plots horizontal grid lines at the positions
% specified by Y. GRIDXY uses the current axes, if any. Lines outside
% the plot area are plotted but not shown. When X or Y is empty no vertical
% or horizontal lines are plotted.
%
% The lines are plotted as a single graphics object. H = GRIDXY(..) returns
% a graphics handle to that line object.
%
% GRIDXY(..., 'Prop1','Val1','Prop2','Val2', ...) uses the properties
% and values specified for color, linestyle, etc. Execute GET(H), where H is
% a line handle, to see a list of line object properties and their current values.
% Execute SET(H) to see a list of line object properties and legal property values.
%
% Examples
% % some random plot
% plot(10*rand(100,1), 10*rand(100,1),'bo') ;
% % horizontal red dashed grid
% gridxy([1.1 3.2 4.5],'Color','r','Linestyle',':') ;
% % vertical solid thicker yellowish grid, and store the handle
% h = gridxy([],[2.1:0.7:5 8],'Color',[0.9 1.0 0.2],'linewidth',3) ;
%
% GRIDXY can be used to plot a irregular grid on the axes.
%
% See also PLOT, REFLINE, GRID, AXES, REFLINEXY
% NOTE: This function was previously known as XYREFLINE
% for Matlab R13
% version 2.2 (feb 2008)
% (c) Jos van der Geest
% email: jos@jasen.nl
% History
% Created (1.0) feb 2006
% 2.0 apr 2007 - renamed from reflinexy to gridxy, reflinexy is now used
% for plotting intersection between X and Y axes
% 2.1 apr 2007 - add error check for line properties
% 2.2 feb 2008 - added set(gca,'layer','top') to put gridlines behind the
% axis tick marks
error(nargchk(1,Inf,nargin)) ;
% check the arguments
if ~isnumeric(x),
error('Numeric argument expected') ;
end
if nargin==1,
y = [] ;
va = [] ;
else
va = varargin ;
if ischar(va{1}),
% optional arguments are
y = [] ;
elseif isnumeric(va{1})
y = va{1} ;
va = va(2:end) ;
else
error('Invalid second argument') ;
end
if mod(size(va),2) == 1,
error('Property-Value have to be pairs') ;
end
end
% get the axes to plot in
hca=get(get(0,'currentfigure'),'currentaxes');
if isempty(hca),
warning('No current axes found') ;
return ;
end
% get the current limits of the axis
% used for limit restoration later on
xlim = get(hca,'xlim') ;
ylim = get(hca,'ylim') ;
% setup data for the vertical lines
xx1 = repmat(x(:).',3,1) ;
yy1 = repmat([ylim(:) ; nan],1,numel(x)) ;
% setup data for the horizontal lines
xx2 = repmat([xlim(:) ; nan],1,numel(y)) ;
yy2 = repmat(y(:).',3,1) ;
% create data for a single line object
xx1 = [xx1 xx2] ;
if ~isempty(xx1),
yy1 = [yy1 yy2] ;
% add the line to the current axes
np = get(hca,'nextplot') ;
set(hca,'nextplot','add') ;
h = line('xdata',xx1(:),'ydata',yy1(:)) ;
set(hca,'ylim',ylim,'xlim',xlim) ; % reset the limits
uistack(h,'bottom') ; % push lines to the bottom of the graph
set(hca,'nextplot',np,'Layer','top') ; % reset the nextplot state
if ~isempty(va),
try
set(h,va{:}) ; % set line properties
catch
msg = lasterror ;
error(msg.message(21:end)) ;
end
end
else
h = [] ;
end
if nargout==1, % if requested return handle
hh = h ;
end

View File

@ -0,0 +1,16 @@
close all
% histogram
figure()
x = randn(2000,1);
hist(x, 50);
h = findobj(gca, 'Type','patch');
set(h(1), 'FaceColor',[.2,.2,.2], 'EdgeColor','w', 'linewidth',2)
grid('off')
h = gridxy([],get(gca,'ytick'),'color','w','linewidth',2)
box('off');
uistack(h, 'top')
xlabel('Data')
ylabel('Count')
set(gcf, 'PaperUnits', 'centimeters');
set(gcf, 'PaperSize', [11.7 9.0]);
set(gcf, 'PaperPosition',[0.0 0.0 11.7 9.0]);