diff --git a/statistics/code/bootstrapsem.m b/statistics/code/bootstrapsem.m index b5a7cbe..18ebae3 100644 --- a/statistics/code/bootstrapsem.m +++ b/statistics/code/bootstrapsem.m @@ -1,23 +1,24 @@ -nsamples = 1000 -resample = 500 - - x = randn( nsamples, 1 ); -sem = std(x)/sqrt(nsamples); - -mu = zeros( resample, 1 ); -for i = 1:resample - % resample: - xr = x(randi(nsamples, nsamples, 1)); - % compute statistics on sample: - mu(i) = mean(xr); -end -bootsem = std( mu ); - -hold on -hist( x, 20 ); -hist( mu, 20 ); -hold off - -disp(['bootstrap standard error: ', num2str(bootsem)]); -disp(['standard error: ', num2str(sem)]); - +nsamples = 100; +nresamples = 1000; + +% draw a SRS (simple random sample, "Stichprobe") from the population: +x = randn( 1, nsamples ); +fprintf('%-30s %-5s %-5s %-5s\n', '', 'mean', 'stdev', 'sem' ) +fprintf('%30s %5.2f %5.2f %5.2f\n', 'single SRS', mean( x ), std( x ), std( x )/sqrt(nsamples) ) + +% bootstrap the mean: +mus = zeros(nresamples,1); % vector for storing the means +for i = 1:nresamples % loop for generating the bootstraps + inx = randi(nsamples, 1, nsamples); % range, 1D-vector, number + xr = x(inx); % resample the original SRS + mus(i) = mean(xr); % compute statistic of the resampled SRS +end +fprintf('%30s %5.2f %5.2f -\n', 'bootstrapped distribution', mean( mus ), std( mus ) ) + +% many SRS (we can do that with the random number generator, but not in real life!): +musrs = zeros(nresamples,1); % vector for the means of each SRS +for i = 1:nresamples + x = randn( 1, nsamples ); % draw a new SRS + musrs(i) = mean( x ); % compute its mean +end +fprintf('%30s %5.2f %5.2f -\n', 'sampling distribution', mean( musrs ), std( musrs ) ) diff --git a/statistics/code/gaussianbins.m b/statistics/code/gaussianbins.m index effe1fd..717f4ea 100644 --- a/statistics/code/gaussianbins.m +++ b/statistics/code/gaussianbins.m @@ -1,18 +1,26 @@ x = randn( 100, 1 ); % generate some data -bins1 = -4:2:4; % large bins -bins2 = -4:0.5:4; % small bins +db1=2; +db2 = 0.5; +bins1 = -4:db1:4; % large bins +bins2 = -4:db2:4; % small bins +[h1,b1] = hist(x,bins1); +[h2,b2] = hist(x,bins2); + subplot( 1, 2, 1 ); -hold on; -hist( x, bins1 ); -hist( x, bins2 ); +bar(b1,hn1) +hold on +bar(b2,hn2, 'facecolor', 'r' ) xlabel('x') -ylabel('Frequeny') -hold off; -subplot( 1, 2, 2 ); -hold on; -% normalize to the rigtht bin size: -hist( x, bins1, 1.0/(bins1(2)-bins1(1)) ); -hist( x, bins2, 1.0/(bins2(2)-bins2(1)) ); +ylabel('Frequency') +hold off + +% normalize: +hn1 = h1/sum(h1)/db1; +hn2 = h2/sum(h2)/db2; +subplot( 1, 2, 2 ) +bar(b1,hn1) +hold on +bar(b2,hn2, 'facecolor', 'r' ) xlabel('x') ylabel('Probability density') -hold off; +hold off diff --git a/statistics/code/randomwalkstatistics.m b/statistics/code/randomwalkstatistics.m deleted file mode 100644 index 43632cd..0000000 --- a/statistics/code/randomwalkstatistics.m +++ /dev/null @@ -1,25 +0,0 @@ -p = 0.5; -nsteps = 100; -nwalks = 1000; - -y = zeros( nwalks, nsteps/10 ); -for k = 1:length( y ) - x = randomwalk( nsteps, p ); - for j = 1:nsteps/10 - y(k,j) = x((j-1)*10+1); - end - %plot( x ) - %pause( 1 ) - if rem(k,100) == 0 - %[h1,b1] = hist( y(1:k,1), [-50:2:50] ); - %[h2,b2] = hist( y(1:k,2), [-50:2:50] ); - %bar( b1, h1, 1.0, 'b' ); - %hold on; - %bar( b2, h2, 'FaceColor', 'r' ); - %hold off; - sdev = var( y(1:k,:), 1 ); - plot( sdev ) - pause( 1.0 ); - end -end - diff --git a/statistics/code/sprintfexamples.m b/statistics/code/sprintfexamples.m new file mode 100644 index 0000000..b8f6b75 --- /dev/null +++ b/statistics/code/sprintfexamples.m @@ -0,0 +1,48 @@ +% sprintf returns a string. +% This string can be used to annotate plots using the text() function. +s = sprintf( 'x=%f', pi ) + +% fprintf writes directly to console (or into files). +% for fprintf you usually want to add the line break '\n': + +% '%f' formats floating point numbers: +fprintf( 'x=%f\n', pi ) +% The '%f' formatting string can be anywhere in the string: +fprintf( 'x=%fms\n', pi ) +% There can be arbitrary many '%' formatting strings: +fprintf( 'x=%fms, y=%fkHz\n', pi, 2*pi ) +% The '%' itself is generated by '%%': +fprintf( 'x=%f%%\n', pi ) +% A point followed by a number sets the number of digits after the point: +fprintf( 'x=%.2fms\n', pi ) +% The numbers are appropriately rounded: +fprintf( 'x=%.3fms\n', pi ) +% A number right before the point sets the width of the generated output: +fprintf( 'x=%10.3fms\n', pi ) +% '%e' also formats floating point numbers but forces to write in +% exponential style: +fprintf( 'x=%e\n', pi ) +% again, a point and number set the number of digits after the point. +fprintf( 'x=%.1e\n', pi ) +% '%g% formats the floating point number to a given number of valid digits +% (default is 5): +fprintf( 'x=%g\n', pi ) +% The number of valid digits is not the number of digits after the point: +fprintf( 'x=%.2g\n', pi ) +fprintf( 'x=%.2g\n', 10.123 ) +fprintf( 'x=%.2g\n', 18765.123 ) +fprintf( 'x=%.5g\n', 18765.123 ) + +% '%d' formats integers: +fprintf( 'x=%d\n', 5 ) +% the number defines the width of the output: +fprintf( 'x=%3d\n', 5 ) +% precedig the width with a '0' fills up the space with leading zeros: +fprintf( 'x=%03d\n', 5 ) + +% '%s' formats a string: +fprintf( 'x=%s\n', 'hallo' ) +% ... aligned to the right: +fprintf( 'x=%10s\n', 'hallo' ) +% ... unless the width is negative: +fprintf( 'x=%-10s!\n', 'hallo' ) diff --git a/statistics/exercises/Makefile b/statistics/exercises/Makefile new file mode 100644 index 0000000..925485d --- /dev/null +++ b/statistics/exercises/Makefile @@ -0,0 +1,34 @@ +TEXFILES=$(wildcard statistics??.tex) +EXERCISES=$(TEXFILES:.tex=.pdf) +SOLUTIONS=$(EXERCISES:statistics%=solutions%) + +.PHONY: pdf exercises solutions watch watchexercises watchsolutions clean + +pdf : $(SOLUTIONS) $(EXERCISES) + +exercises : $(EXERCISES) + +solutions : $(SOLUTIONS) + +$(SOLUTIONS) : solutions%.pdf : statistics%.tex instructions.tex + { echo "\\documentclass[answers,12pt,a4paper,pdftex]{exam}"; sed -e '1d' $<; } > $(patsubst %.pdf,%.tex,$@) + pdflatex -interaction=scrollmode $(patsubst %.pdf,%.tex,$@) | tee /dev/stderr | fgrep -q "Rerun to get cross-references right" && pdflatex -interaction=scrollmode $(patsubst %.pdf,%.tex,$@) || true + rm $(patsubst %.pdf,%,$@).[!p]* + +$(EXERCISES) : %.pdf : %.tex instructions.tex + pdflatex -interaction=scrollmode $< | tee /dev/stderr | fgrep -q "Rerun to get cross-references right" && pdflatex -interaction=scrollmode $< || true + +watch : + while true; do ! make -q pdf && make pdf; sleep 0.5; done + +watchexercises : + while true; do ! make -q exercises && make exercises; sleep 0.5; done + +watchsolutions : + while true; do ! make -q solutions && make solutions; sleep 0.5; done + +clean : + rm -f *~ *.aux *.log *.out + +cleanup : clean + rm -f $(SOLUTIONS) $(EXERCISES) diff --git a/statistics/code/bootstraptymus.m b/statistics/exercises/bootstraptymus.m similarity index 100% rename from statistics/code/bootstraptymus.m rename to statistics/exercises/bootstraptymus.m diff --git a/statistics/exercises/centrallimit.m b/statistics/exercises/centrallimit.m new file mode 100644 index 0000000..9f492bd --- /dev/null +++ b/statistics/exercises/centrallimit.m @@ -0,0 +1,72 @@ +%% central limit theorem +n = 10000; +m = 10; % number of loops + +%% (b) a single random number: +x = rand( n, 1 ); + +%% (c) plot probability density: +%histogram( x, 'Normalization', 'pdf' ); +[h,b] = hist( x, 20 ); +h = h/sum(h)/(b(2)-b(1)); % normalization +bar(b, h) +title('A uniform distribution') +xlabel('x') +ylabel('probability density') +pause( 2.0 ) + +%% (d) sum of two random numbers: +y = rand( n, 1 ); +x = x + y; +%histogram( x, 'Normalization', 'pdf' ); +[h,b] = hist( x, 20 ); +h = h/sum(h)/(b(2)-b(1)); % normalization +bar(b, h) +title('Sum of two uniform distributions') +xlabel('x') +ylabel('probability density') +pause( 2.0 ) + +%% (f) sum up more distributions: +x = zeros( n, 1 ); +means = zeros( m, 1 ); +stds = zeros( m, 1 ); +for i=1:m + y = rand( n, 1 ); % new uniform distributed numbers + x = x + y; % add them to the sum + mu = mean(x); % compute mean + sd = std(x); % compute standard deviation + means(i) = mu; % store mean + stds(i) = sd; % store standard deviation + %xx = min(x):0.01:max(x); + xx = -1:0.01:i+1; % x-axis values for plot of pdf + p = exp(-0.5*(xx-mu).^2/sd^2)/sqrt(2*pi*sd^2); % pdf + plot(xx, p, 'r', 'linewidth', 6 ) + ns = sprintf( 'N=%d', i ); + text( 0.1, 0.9, ns, 'units', 'normalized' ) + hold on + %histogram( x, 20, 'Normalization', 'pdf' ); + [h,b] = hist( x, 20 ); + h = h/sum(h)/(b(2)-b(1)); % normalization + bar(b, h) + hold off + xlabel( 'x' ) + ylabel( 'summed pdf' ) + if i < 6 + pause( 3.0 ) + end +end + +%% (h) mean and standard deviation in dependence on number of summed up distributions: +nx = 1:m; +plot( nx, means, 'b', 'linewidth', 4 ); +hold on +plot( nx, stds, 'r', 'linewidth', 4 ); +xx = 0:0.01:m; +sdu = 1.0/sqrt(12); % standarad deviation of the uniform distribution +plot( xx, sqrt(xx)*sdu, 'k' ) +legend( 'mean', 'std', 'theory' ) +xlabel('N') +hold off + + diff --git a/statistics/exercises/correlationsignificance.m b/statistics/exercises/correlationsignificance.m new file mode 100644 index 0000000..7a0f5f0 --- /dev/null +++ b/statistics/exercises/correlationsignificance.m @@ -0,0 +1,49 @@ +%% (a) generate correlated data +n=1000; +a=0.2; +x = randn(n, 1); +y = randn(n, 1) + a*x; + +%% (b) scatter plot: +subplot(1, 2, 1); +%scatter(x, y ); % either scatter ... +plot(x, y, 'o' ); % ... or plot - same plot. + +%% (d) correlation coefficient: +rd = corr(x, y); +%rd = r(0, 1); +fprintf('correlation coefficient = %.2f\n', rd ); + +%% (f) permutation: +nperm = 1000; +rs = zeros(nperm,1); +for i=1:nperm + xr=x(randperm(length(x))); % shuffle x + yr=y(randperm(length(y))); % shuffle y + rs(i) = corr(xr, yr); + %rs(i) = r(0,1); +end + +%% (g) pdf of the correlation coefficients: +[h,b] = hist(rs, 20 ); +h = h/sum(h)/(b(2)-b(1)); % normalization + +%% (h) significance: +rq = quantile(rs, 0.95); +fprintf('correlation coefficient at 5%% significance = %.2f\n', rq ); +if rd >= rq + fprintf('--> correlation r=%.2f is significant\n', rd); +else + fprintf('--> r=%.2f is not a significant correlation\n', rd); +end + +%% plot: +subplot(1, 2, 2) +hold on; +bar(b, h, 'facecolor', 'b'); +bar(b(b>=rq), h(b>=rq), 'facecolor', 'r'); +plot( [rd rd], [0 4], 'r', 'linewidth', 2 ); +xlabel('correlation coefficient'); +ylabel('probability density'); +hold off; + diff --git a/statistics/exercises/die1.m b/statistics/exercises/die1.m new file mode 100644 index 0000000..d407ff1 --- /dev/null +++ b/statistics/exercises/die1.m @@ -0,0 +1,39 @@ +n = 10000; + +%% (a) simulate n times rolling a die: +x = rollthedie( n ); + +%% (b) probability P(3): +P3 = sum(x == 3)/length(x); +fprintf( 'P(3)=%.3f, expected is %.3f\n', P3, 1/6 ); + +for i =1:6 + P = sum(x == i)/length(x); + fprintf( 'P(%d)=%.3f, expected is %.3f\n', i, P, 1/6 ); +end + +%% (c) P(i) +P = zeros(1, 6); +for i =1:6 + P(i) = sum(x == i)/length(x); +end +subplot( 1, 2, 1 ) +plot( [0 7], [1/6 1/6], 'r', 'linewidth', 6 ) +hold on +bar( P ); +hold off +xlim( [ 0 7 ] ); +xlabel('Eyes'); +ylabel('Probability'); + +%% (d) histogram of x +subplot( 1, 2, 2 ); +diehist( x ); + +%% (e) loaded die +% eye 1 to 5 have P=1/8, eye 6 has P = 3/8 ! +x = randi( 8, 1, n ); % random numbers from 1 to 8 +x(x>6) = 6; % set numbers 7 and 8 to 6 +diehist( x ); + + diff --git a/statistics/exercises/die2.m b/statistics/exercises/die2.m new file mode 100644 index 0000000..407592b --- /dev/null +++ b/statistics/exercises/die2.m @@ -0,0 +1,24 @@ +ndies = 20; +n = 100; +P = zeros(ndies, 6); +for i = 1:ndies + % (a) roll a single die: + x = rollthedie( n ); + % (b) compute normalized histogram: + [h,b] = hist( x, 1:6 ); + h = h/sum(h); % normalization + % (c) store the histograms: + P(i,:) = h; +end +% (c) mean and standard deviation for each eye: +m = mean(P, 1); +s = std(P, 1); +% (d) plot results: +bar(m, 'facecolor', [0.8 0 0]); % darker red +hold on; +errorbar(m, s, '.k', 'linewidth', 2 ); % k is black +xlim( [ 0, 7 ] ); +xlabel('Eyes'); +ylabel('Probability'); +hold off; + diff --git a/statistics/exercises/diehist.m b/statistics/exercises/diehist.m new file mode 100644 index 0000000..4a8c24a --- /dev/null +++ b/statistics/exercises/diehist.m @@ -0,0 +1,13 @@ +function diehist( x ) +% plots a normalized histogram of random numbers x drawn from rolling a +% die. + [h,b] = hist( x, 1:6 ); + h = h/sum(h); % normalization + plot( [0 7], [1/6 1/6], 'r', 'linewidth', 6 ) + hold on + bar( b, h ); + hold off + xlim( [ 0, 7 ] ); + xlabel('Eyes'); + ylabel('Probability'); +end diff --git a/statistics/exercises/instructions.tex b/statistics/exercises/instructions.tex new file mode 100644 index 0000000..12e9e24 --- /dev/null +++ b/statistics/exercises/instructions.tex @@ -0,0 +1,41 @@ +\vspace*{-6.5ex} +\begin{center} +\textbf{\Large Einf\"uhrung in die wissenschaftliche Datenverarbeitung}\\[1ex] +{\large Jan Grewe, Jan Benda}\\[-3ex] +Abteilung Neuroethologie \hfill --- \hfill Institut f\"ur Neurobiologie \hfill --- \hfill \includegraphics[width=0.28\textwidth]{UT_WBMW_Black_RGB} \\ +\end{center} + +\ifprintanswers% +\else + +% Die folgenden Aufgaben dienen der Wiederholung, \"Ubung und +% Selbstkontrolle und sollten eigenst\"andig bearbeitet und gel\"ost +% werden. Die L\"osung soll in Form eines einzelnen Skriptes (m-files) +% im ILIAS hochgeladen werden. Jede Aufgabe sollte in einer eigenen +% ``Zelle'' gel\"ost sein. Die Zellen \textbf{m\"ussen} unabh\"angig +% voneinander ausf\"uhrbar sein. Das Skript sollte nach dem Muster: +% ``variablen\_datentypen\_\{nachname\}.m'' benannt werden +% (z.B. variablen\_datentypen\_mueller.m). + +\begin{itemize} +\item \"Uberzeuge dich von jeder einzelnen Zeile deines Codes, dass + sie auch wirklich das macht, was sie machen soll! Teste dies mit + kleinen Beispielen direkt in der Kommandozeile. +\item Versuche die L\"osungen der Aufgaben m\"oglichst in + sinnvolle kleine Funktionen herunterzubrechen. + Sobald etwas \"ahnliches mehr als einmal berechnet werden soll, + lohnt es sich eine Funktion daraus zu schreiben! +\item Teste rechenintensive \code{for} Schleifen, Vektoren, Matrizen + zuerst mit einer kleinen Anzahl von Wiederholungen oder kleiner + Gr\"o{\ss}e, und benutze erst am Ende, wenn alles \"uberpr\"uft + ist, eine gro{\ss}e Anzahl von Wiederholungen oder Elementen, um eine gute + Statistik zu bekommen. +\item Benutze die Hilfsfunktion von \code{matlab} (\code{help + commando} oder \code{doc commando}) und das Internet, um + herauszufinden, wie bestimmte \code{matlab} Funktionen zu verwenden + sind und was f\"ur M\"oglichkeiten sie bieten. + Auch zu inhaltlichen Konzepten bietet das Internet oft viele + Antworten! +\end{itemize} + +\fi diff --git a/statistics/exercises/normprobs.m b/statistics/exercises/normprobs.m new file mode 100644 index 0000000..c7e4f37 --- /dev/null +++ b/statistics/exercises/normprobs.m @@ -0,0 +1,43 @@ +%% (a) generate normal distributed random numbers: +n = 10000; +x = randn( n, 1 ); + +%% (b) +nsig = sum((x>=-1.0)&(x<=1.0)); +Psig = nsig/length(x); +fprintf('%d of %d data elements, i.e. %.2f%% are contained in the interval -1 to +1\n\n', ... + nsig, length(x), 100.0*Psig ); + +%% (c) +dx = 0.01; +xx = -10:dx:10; % x-values +pg = exp(-0.5*xx.^2)/sqrt(2*pi); % y-values Gaussian pdf +% integral over the whole range: +P = sum(pg)*dx; +fprintf( 'Integral over the Gaussian pdf is %.3f\n', P ); +% integral from -1 to 1: +P = sum(pg((xx>=-1.0)&(xx<=1.0)))*dx; % we need to use xx, not the random numbers x! +fprintf( 'Integral over the Gaussian pdf from -1 to 1 is %.4f\n', P ); + +%% (d) +P = sum(pg((xx>=-2.0)&(xx<=2.0)))*dx; +fprintf( 'Integral over the Gaussian pdf from -2 to 2 is %.4f\n', P ); +P = sum(pg((xx>=-3.0)&(xx<=3.0)))*dx; +fprintf( 'Integral over the Gaussian pdf from -3 to 3 is %.4f\n\n', P ); + +%% (e) probability of small ranges +nr = 50; +xs = zeros(nr, 1); % size of integration interval +Ps = zeros(nr, 1); % storage +for i = 1:nr + % upper limit goes from 4.0 down to 0.0: + xupper = 3.0*(nr-i)/nr; + xs(i) = xupper; + % integral from 0 to xupper: + Ps(i) = sum(pg((xx>=0.0)&(xx<=xupper)))*dx; +end +plot( xs, Ps, 'linewidth', 3 ) +ylim([0 0.55]) +xlabel('Integration interval') +ylabel('Probability') +fprintf('The probability P(0.1234) = %.4f\n\n', sum(x == 0.1234)/length(x) ); diff --git a/statistics/code/randomwalk.m b/statistics/exercises/randomwalk.m similarity index 100% rename from statistics/code/randomwalk.m rename to statistics/exercises/randomwalk.m diff --git a/statistics/exercises/randomwalkstatistics.m b/statistics/exercises/randomwalkstatistics.m new file mode 100644 index 0000000..8653aa6 --- /dev/null +++ b/statistics/exercises/randomwalkstatistics.m @@ -0,0 +1,51 @@ +p = 0.5; + +%% (b) +nwalks = [100 1000, 10000]; +for i=1:length(nwalks) + subplot( 3, 1, i ); + for k=1:10 + x = randomwalk( nwalks(i), p ); + plot( x ); + hold on; + end + text( 0.05, 0.8, sprintf( 'N=%d', nwalks(i)), 'units', 'normalized' ) + xlabel( 'Number of steps' ); + ylabel( 'Position of walker' ) + hold off; +end +pause( 5.0 ) + +nsteps = 100; +nwalks = 10000; +subplot( 1, 1, 1 ) +y = zeros( nwalks, nsteps ); +for k = 1:nwalks + x = randomwalk( nsteps, p ); + y(k,:) = x; % store random walk +end +ns = 1:nsteps; +mu = mean(y, 1); +sdev = std(y, 1); +plot( ns, mu, 'b', 'linewidth', 4 ) +hold on +plot( ns, sdev, 'r', 'linewidth', 4 ) +xx = 0:0.01:nsteps; +plot( xx, sqrt(xx), 'k' ) +plot( xx, zeros(length(xx),1), 'k' ) +legend( 'mean', 'std', 'theory' ) +hold off +pause( 3.0 ); + +%% (d) histograms: +tinx = [100, 30, 10]; +colors = [ 0 0 1; 0.5 0 0.5; 1 0 0 ]; +for i = 1:length(tinx) + [h,b] = hist( y(:,tinx(i)), 20); + h = h/sum(h)/(b(2)-b(1)); + bar(b, h, 1.0, 'facecolor', colors(i,:)) + hold on; +end +hold off; +xlabel('Position of walker'); +ylabel('Probability density'); diff --git a/statistics/exercises/rollthedie.m b/statistics/exercises/rollthedie.m new file mode 100644 index 0000000..1842da8 --- /dev/null +++ b/statistics/exercises/rollthedie.m @@ -0,0 +1,4 @@ +function x = rollthedie( n ) +% return a vector with the result of rolling a die n times + x = randi( [1, 6], n, 1 ); +end diff --git a/statistics/exercises/descriptivestatistics-01.tex b/statistics/exercises/statistics01.tex similarity index 70% rename from statistics/exercises/descriptivestatistics-01.tex rename to statistics/exercises/statistics01.tex index 9800e54..d78a0b3 100644 --- a/statistics/exercises/descriptivestatistics-01.tex +++ b/statistics/exercises/statistics01.tex @@ -1,22 +1,23 @@ \documentclass[12pt,a4paper,pdftex]{exam} \usepackage[german]{babel} -\usepackage{natbib} -\usepackage{graphicx} -\usepackage[small]{caption} -\usepackage{sidecap} \usepackage{pslatex} -\usepackage{amsmath} -\usepackage{amssymb} -\setlength{\marginparwidth}{2cm} +\usepackage[mediumspace,mediumqspace,Gray]{SIunits} % \ohm, \micro +\usepackage{xcolor} +\usepackage{graphicx} \usepackage[breaklinks=true,bookmarks=true,bookmarksopen=true,pdfpagemode=UseNone,pdfstartview=FitH,colorlinks=true,citecolor=blue]{hyperref} -%%%%% text size %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%% layout %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \usepackage[left=20mm,right=20mm,top=25mm,bottom=25mm]{geometry} \pagestyle{headandfoot} -\header{{\bfseries\large \"Ubung 1}}{{\bfseries\large Deskriptive Statistik}}{{\bfseries\large 19. Oktober, 2015}} +\ifprintanswers +\newcommand{\stitle}{: L\"osungen} +\else +\newcommand{\stitle}{} +\fi +\header{{\bfseries\large \"Ubung 1\stitle}}{{\bfseries\large Statistik}}{{\bfseries\large 19. Oktober, 2015}} \firstpagefooter{Prof. Dr. Jan Benda}{Phone: 29 74573}{Email: -jan.grewe@uni-tuebingen.de} +jan.benda@uni-tuebingen.de} \runningfooter{}{\thepage}{} \setlength{\baselineskip}{15pt} @@ -24,11 +25,39 @@ jan.grewe@uni-tuebingen.de} \setlength{\parskip}{0.3cm} \renewcommand{\baselinestretch}{1.15} -\newcommand{\qt}[1]{\textbf{#1}\\} -\newcommand{\pref}[1]{(\ref{#1})} -\newcommand{\extra}{--- Zusatzaufgabe ---\ \mbox{}} -\newcommand{\code}[1]{\texttt{#1}} - +%%%%% listings %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\usepackage{listings} +\lstset{ + language=Matlab, + basicstyle=\ttfamily\footnotesize, + numbers=left, + numberstyle=\tiny, + title=\lstname, + showstringspaces=false, + commentstyle=\itshape\color{darkgray}, + breaklines=true, + breakautoindent=true, + columns=flexible, + frame=single, + xleftmargin=1em, + xrightmargin=1em, + aboveskip=10pt +} + +%%%%% math stuff: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\usepackage{amsmath} +\usepackage{amssymb} +\usepackage{bm} +\usepackage{dsfont} +\newcommand{\naZ}{\mathds{N}} +\newcommand{\gaZ}{\mathds{Z}} +\newcommand{\raZ}{\mathds{Q}} +\newcommand{\reZ}{\mathds{R}} +\newcommand{\reZp}{\mathds{R^+}} +\newcommand{\reZpN}{\mathds{R^+_0}} +\newcommand{\koZ}{\mathds{C}} + +%%%%% page breaks %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \newcommand{\continue}{\ifprintanswers% \else \vfill\hspace*{\fill}$\rightarrow$\newpage% @@ -43,66 +72,50 @@ jan.grewe@uni-tuebingen.de} \else \fi} +%%%%% new commands %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\newcommand{\qt}[1]{\textbf{#1}\\} +\newcommand{\pref}[1]{(\ref{#1})} +\newcommand{\extra}{--- Zusatzaufgabe ---\ \mbox{}} +\newcommand{\code}[1]{\texttt{#1}} + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{document} -\vspace*{-6.5ex} -\begin{center} -\textbf{\Large Einf\"uhrung in die wissenschaftliche Datenverarbeitung}\\[1ex] -{\large Jan Grewe, Jan Benda}\\[-3ex] -Abteilung Neuroethologie \hfill --- \hfill Institut f\"ur Neurobiologie \hfill --- \hfill \includegraphics[width=0.28\textwidth]{UT_WBMW_Black_RGB} \\ -\end{center} - -% Die folgenden Aufgaben dienen der Wiederholung, \"Ubung und -% Selbstkontrolle und sollten eigenst\"andig bearbeitet und gel\"ost -% werden. Die L\"osung soll in Form eines einzelnen Skriptes (m-files) -% im ILIAS hochgeladen werden. Jede Aufgabe sollte in einer eigenen -% ``Zelle'' gel\"ost sein. Die Zellen \textbf{m\"ussen} unabh\"angig -% voneinander ausf\"uhrbar sein. Das Skript sollte nach dem Muster: -% ``variablen\_datentypen\_\{nachname\}.m'' benannt werden -% (z.B. variablen\_datentypen\_mueller.m). - -\begin{itemize} -\item \"Uberzeuge dich von jeder einzelnen Zeile deines Codes, dass sie -auch wirklich das macht, was sie machen soll! Teste dies mit kleinen -Beispielen direkt in der Kommandozeile. -\item Versuche die L\"osungen der folgenden Aufgaben m\"oglichst in -sinnvolle kleine Funktionen herunterzubrechen. -\item Sobald etwas \"ahnliches mehr als einmal berechnet werden soll, -lohnt es sich eine Funktion daraus zu schreiben! -\item Teste rechenintensive \code{for} Schleifen zuerst mit einer kleinen -Anzahl von Wiederholungen, und benutze erst am Ende, wenn alles -stimmt, eine gro{\ss}e Anzahl von Wiederholungen, um eine gute -Statistik zu bekommen. -\item Benutze die Hilfsfunktion von matlab und das Internet, um -herauszufinden wie bestimmte \code{matlab} Funktionen zu verwenden -sind und was f\"ur M\"oglichkeiten sie bieten. -\item Auch zu inhaltlichen Konzepten bietet das Internet oft viele Antworten! -\end{itemize} +\input{instructions} \begin{questions} \question \qt{Wahrscheinlichkeiten eines W\"urfels I} + Der Computer kann auch als W\"urfel verwendet werden! \begin{parts} \part Simuliere 10000 W\"urfe mit dem W\"urfel durch Erzeugung von ganzzahligen Zufallszahlen mit den Augenzahlen $x_i = 1, 2, \ldots 6$ . + \part Berechne die Wahrscheinlichkeit $P(3)$ des Auftretens der Augenzahl drei durch Bestimmung der Anzahl der Dreien im Datensatz.\\ Entspricht das Ergebnis deiner Erwartung?\\ \"Uberpr\"ufe auch die Wahrscheinlichkeit $P(x_i)$ der anderen Zahlen.\\ Ist das ein fairer W\"urfel? + \part Speicher die berechneten Wahrscheinlichkeiten $P(x_i)$ f\"ur das Auftreten der gew\"urfelten Zahlen in einem Vektor und benutze die \code{bar} Funktion, um diese Wahrscheinlichkeiten als Funktion der Augenzahl zu plotten. + \part Erstelle in einem weiterem Plot ein entsprechendes normiertes Histogramm mit der \code{hist} Funktion. + \part \extra Wie k\"onnte man einen gezinkten W\"urfel simulieren, bei dem die sechs dreimal so h\"aufig wie die anderen Zahlen gew\"urfelt wird?\\ Fertige von diesem W\"urfel ein Histogram aus 10000 W\"urfen an. \end{parts} +\begin{solution} + \lstinputlisting{rollthedie.m} + \lstinputlisting{diehist.m} + \lstinputlisting{die1.m} +\end{solution} \continue @@ -117,6 +130,9 @@ Wir werten nun das Verhalten mehrerer W\"urfel aus. \part Stelle das Ergebnis mit einem S\"aulenplot mit Fehlerbalken dar (\code{bar} mit \code{errorbar} Funktionen). \end{parts} +\begin{solution} + \lstinputlisting{die2.m} +\end{solution} \question \qt{Wahrscheinlichkeiten der Normalverteilung} @@ -155,6 +171,9 @@ Mittelwert enthalten ist. Wie bekommt man mit \code{randn} Zufallszahlen mit beliebiger Standardabweichung und Mittelwerten? \end{parts} +\begin{solution} + \lstinputlisting{normprobs.m} +\end{solution} \end{questions} diff --git a/statistics/exercises/descriptivestatistics-02.tex b/statistics/exercises/statistics02.tex similarity index 70% rename from statistics/exercises/descriptivestatistics-02.tex rename to statistics/exercises/statistics02.tex index 3f92aa5..36216be 100644 --- a/statistics/exercises/descriptivestatistics-02.tex +++ b/statistics/exercises/statistics02.tex @@ -1,22 +1,23 @@ \documentclass[12pt,a4paper,pdftex]{exam} \usepackage[german]{babel} -\usepackage{natbib} -\usepackage{graphicx} -\usepackage[small]{caption} -\usepackage{sidecap} \usepackage{pslatex} -\usepackage{amsmath} -\usepackage{amssymb} -\setlength{\marginparwidth}{2cm} +\usepackage[mediumspace,mediumqspace,Gray]{SIunits} % \ohm, \micro +\usepackage{xcolor} +\usepackage{graphicx} \usepackage[breaklinks=true,bookmarks=true,bookmarksopen=true,pdfpagemode=UseNone,pdfstartview=FitH,colorlinks=true,citecolor=blue]{hyperref} -%%%%% text size %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%% layout %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \usepackage[left=20mm,right=20mm,top=25mm,bottom=25mm]{geometry} \pagestyle{headandfoot} -\header{{\bfseries\large \"Ubung 2}}{{\bfseries\large Deskriptive Statistik}}{{\bfseries\large 19. Oktober, 2015}} +\ifprintanswers +\newcommand{\stitle}{: L\"osungen} +\else +\newcommand{\stitle}{} +\fi +\header{{\bfseries\large \"Ubung 2\stitle}}{{\bfseries\large Statistik}}{{\bfseries\large 20. Oktober, 2015}} \firstpagefooter{Prof. Dr. Jan Benda}{Phone: 29 74573}{Email: -jan.grewe@uni-tuebingen.de} +jan.benda@uni-tuebingen.de} \runningfooter{}{\thepage}{} \setlength{\baselineskip}{15pt} @@ -24,11 +25,39 @@ jan.grewe@uni-tuebingen.de} \setlength{\parskip}{0.3cm} \renewcommand{\baselinestretch}{1.15} -\newcommand{\qt}[1]{\textbf{#1}\\} -\newcommand{\pref}[1]{(\ref{#1})} -\newcommand{\extra}{--- Zusatzaufgabe ---\ \mbox{}} -\newcommand{\code}[1]{\texttt{#1}} - +%%%%% listings %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\usepackage{listings} +\lstset{ + language=Matlab, + basicstyle=\ttfamily\footnotesize, + numbers=left, + numberstyle=\tiny, + title=\lstname, + showstringspaces=false, + commentstyle=\itshape\color{darkgray}, + breaklines=true, + breakautoindent=true, + columns=flexible, + frame=single, + xleftmargin=1em, + xrightmargin=1em, + aboveskip=10pt +} + +%%%%% math stuff: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\usepackage{amsmath} +\usepackage{amssymb} +\usepackage{bm} +\usepackage{dsfont} +\newcommand{\naZ}{\mathds{N}} +\newcommand{\gaZ}{\mathds{Z}} +\newcommand{\raZ}{\mathds{Q}} +\newcommand{\reZ}{\mathds{R}} +\newcommand{\reZp}{\mathds{R^+}} +\newcommand{\reZpN}{\mathds{R^+_0}} +\newcommand{\koZ}{\mathds{C}} + +%%%%% page breaks %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \newcommand{\continue}{\ifprintanswers% \else \vfill\hspace*{\fill}$\rightarrow$\newpage% @@ -43,44 +72,18 @@ jan.grewe@uni-tuebingen.de} \else \fi} +%%%%% new commands %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\newcommand{\qt}[1]{\textbf{#1}\\} +\newcommand{\pref}[1]{(\ref{#1})} +\newcommand{\extra}{--- Zusatzaufgabe ---\ \mbox{}} +\newcommand{\code}[1]{\texttt{#1}} + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{document} -\vspace*{-6.5ex} -\begin{center} -\textbf{\Large Einf\"uhrung in die wissenschaftliche Datenverarbeitung}\\[1ex] -{\large Jan Grewe, Jan Benda}\\[-3ex] -Abteilung Neuroethologie \hfill --- \hfill Institut f\"ur Neurobiologie \hfill --- \hfill \includegraphics[width=0.28\textwidth]{UT_WBMW_Black_RGB} \\ -\end{center} - -% Die folgenden Aufgaben dienen der Wiederholung, \"Ubung und -% Selbstkontrolle und sollten eigenst\"andig bearbeitet und gel\"ost -% werden. Die L\"osung soll in Form eines einzelnen Skriptes (m-files) -% im ILIAS hochgeladen werden. Jede Aufgabe sollte in einer eigenen -% ``Zelle'' gel\"ost sein. Die Zellen \textbf{m\"ussen} unabh\"angig -% voneinander ausf\"uhrbar sein. Das Skript sollte nach dem Muster: -% ``variablen\_datentypen\_\{nachname\}.m'' benannt werden -% (z.B. variablen\_datentypen\_mueller.m). - - -\begin{itemize} -\item \"Uberzeuge dich von jeder einzelnen Zeile deines Codes, dass sie -auch wirklich das macht, was sie machen soll! Teste dies mit kleinen -Beispielen direkt in der Kommandozeile. -\item Versuche die L\"osungen der folgenden Aufgaben m\"oglichst in -sinnvolle kleine Funktionen herunterzubrechen. -\item Sobald etwas \"ahnliches mehr als einmal berechnet werden soll, -lohnt es sich eine Funktion daraus zu schreiben! -\item Teste rechenintensive \code{for} Schleifen zuerst mit einer kleinen -Anzahl von Wiederholungen, und benutze erst am Ende, wenn alles -stimmt, eine gro{\ss}e Anzahl von Wiederholungen, um eine gute -Statistik zu bekommen. -\item Benutze die Hilfsfunktion von matlab und das Internet, um -herauszufinden wie bestimmte \code{matlab} Funktionen zu verwenden -sind und was f\"ur M\"oglichkeiten sie bieten. -\item Auch zu inhaltlichen Konzepten bietet das Internet oft viele Antworten! -\end{itemize} +\input{instructions} + \begin{questions} @@ -116,6 +119,9 @@ Den Zentralen Grenzwertsatz wollen wir uns im Folgenden veranschaulichen. \part \extra \"Uberpr\"ufe den Grenzwertsatz in gleicher Weise mit exponentiell verteilten Zufallszahlen (Funktion \code{rande}). \end{parts} +\begin{solution} + \lstinputlisting{centrallimit.m} +\end{solution} \question \qt{Random Walk} @@ -138,6 +144,10 @@ Im folgenden wollen wir einige Eigenschaften des Random Walks bestimmen. \part \extra Erstelle eine Grafik, die die Verteilung der Position eines Random Walkers zu drei verschiedenen Zeitpunkten zeigt. \end{parts} +\begin{solution} + \lstinputlisting{randomwalk.m} + \lstinputlisting{randomwalkstatistics.m} +\end{solution} \question \qt{\extra 2D Random Walk} diff --git a/statistics/exercises/bootstrap-01.tex b/statistics/exercises/statistics03.tex similarity index 68% rename from statistics/exercises/bootstrap-01.tex rename to statistics/exercises/statistics03.tex index a5860e1..6ae5189 100644 --- a/statistics/exercises/bootstrap-01.tex +++ b/statistics/exercises/statistics03.tex @@ -1,20 +1,21 @@ \documentclass[12pt,a4paper,pdftex]{exam} \usepackage[german]{babel} -\usepackage{natbib} -\usepackage{graphicx} -\usepackage[small]{caption} -\usepackage{sidecap} \usepackage{pslatex} -\usepackage{amsmath} -\usepackage{amssymb} -\setlength{\marginparwidth}{2cm} +\usepackage[mediumspace,mediumqspace,Gray]{SIunits} % \ohm, \micro +\usepackage{xcolor} +\usepackage{graphicx} \usepackage[breaklinks=true,bookmarks=true,bookmarksopen=true,pdfpagemode=UseNone,pdfstartview=FitH,colorlinks=true,citecolor=blue]{hyperref} -%%%%% text size %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%% layout %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \usepackage[left=20mm,right=20mm,top=25mm,bottom=25mm]{geometry} \pagestyle{headandfoot} -\header{{\bfseries\large \"Ubung 1}}{{\bfseries\large Bootstrap}}{{\bfseries\large 21. Oktober, 2015}} +\ifprintanswers +\newcommand{\stitle}{: L\"osungen} +\else +\newcommand{\stitle}{} +\fi +\header{{\bfseries\large \"Ubung 3\stitle}}{{\bfseries\large Statistik}}{{\bfseries\large 21. Oktober, 2015}} \firstpagefooter{Prof. Dr. Jan Benda}{Phone: 29 74573}{Email: jan.benda@uni-tuebingen.de} \runningfooter{}{\thepage}{} @@ -24,11 +25,39 @@ jan.benda@uni-tuebingen.de} \setlength{\parskip}{0.3cm} \renewcommand{\baselinestretch}{1.15} -\newcommand{\qt}[1]{\textbf{#1}\\} -\newcommand{\pref}[1]{(\ref{#1})} -\newcommand{\extra}{--- Zusatzaufgabe ---\ \mbox{}} -\newcommand{\code}[1]{\texttt{#1}} - +%%%%% listings %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\usepackage{listings} +\lstset{ + language=Matlab, + basicstyle=\ttfamily\footnotesize, + numbers=left, + numberstyle=\tiny, + title=\lstname, + showstringspaces=false, + commentstyle=\itshape\color{darkgray}, + breaklines=true, + breakautoindent=true, + columns=flexible, + frame=single, + xleftmargin=1em, + xrightmargin=1em, + aboveskip=10pt +} + +%%%%% math stuff: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\usepackage{amsmath} +\usepackage{amssymb} +\usepackage{bm} +\usepackage{dsfont} +\newcommand{\naZ}{\mathds{N}} +\newcommand{\gaZ}{\mathds{Z}} +\newcommand{\raZ}{\mathds{Q}} +\newcommand{\reZ}{\mathds{R}} +\newcommand{\reZp}{\mathds{R^+}} +\newcommand{\reZpN}{\mathds{R^+_0}} +\newcommand{\koZ}{\mathds{C}} + +%%%%% page breaks %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \newcommand{\continue}{\ifprintanswers% \else \vfill\hspace*{\fill}$\rightarrow$\newpage% @@ -43,34 +72,17 @@ jan.benda@uni-tuebingen.de} \else \fi} +%%%%% new commands %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\newcommand{\qt}[1]{\textbf{#1}\\} +\newcommand{\pref}[1]{(\ref{#1})} +\newcommand{\extra}{--- Zusatzaufgabe ---\ \mbox{}} +\newcommand{\code}[1]{\texttt{#1}} + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{document} -\vspace*{-6.5ex} -\begin{center} -\textbf{\Large Einf\"uhrung in die wissenschaftliche Datenverarbeitung}\\[1ex] -{\large Jan Grewe, Jan Benda}\\[-3ex] -Abteilung Neuroethologie \hfill --- \hfill Institut f\"ur Neurobiologie \hfill --- \hfill \includegraphics[width=0.28\textwidth]{UT_WBMW_Black_RGB} \\ -\end{center} - -\begin{itemize} -\item \"Uberzeuge dich von jeder einzelnen Zeile deines Codes, dass sie -auch wirklich das macht, was sie machen soll! Teste dies mit kleinen -Beispielen direkt in der Kommandozeile. -\item Versuche die L\"osungen der folgenden Aufgaben m\"oglichst in -sinnvolle kleine Funktionen herunterzubrechen. -\item Sobald etwas \"ahnliches mehr als einmal berechnet werden soll, -lohnt es sich eine Funktion daraus zu schreiben! -\item Teste rechenintensive \code{for} Schleifen zuerst mit einer kleinen -Anzahl von Wiederholungen, und benutze erst am Ende, wenn alles -stimmt, eine gro{\ss}e Anzahl von Wiederholungen, um eine gute -Statistik zu bekommen. -\item Benutze die Hilfsfunktion von matlab und das Internet, um -herauszufinden wie bestimmte \code{matlab} Funktionen zu verwenden -sind und was f\"ur M\"oglichkeiten sie bieten. -\item Auch zu inhaltlichen Konzepten bietet das Internet oft viele Antworten! -\end{itemize} +\input{instructions} \begin{questions} @@ -82,7 +94,7 @@ sind und was f\"ur M\"oglichkeiten sie bieten. H\"uhnerembryos in mg. \part Lade diese Daten in Matlab (\code{load} Funktion). \part Bestimme Histogramm, Mittelwert und Standardfehler aus den ersten 80 Datenpunkten. - \part Bestimme den Standardfehler aus den ersten 80 Datenpunkten durch 500 Mal Bootstrappen. + \part Bestimme den Standardfehler aus den ersten 80 Datenpunkten durch 500-mal Bootstrappen. \part Bestimme das 95\,\% Konfidenzintervall f\"ur den Mittelwert aus der Bootstrap Verteilung (\code{quantile()} Funktion) --- also das Interval innerhalb dessen mit 95\,\% Wahrscheinlichkeit der @@ -102,7 +114,7 @@ sind und was f\"ur M\"oglichkeiten sie bieten. dieser Mittelwerte. \part Vergleiche diese Wahrscheinlichkeitsdichte mit der Gausskurve. \part Berechne ausserdem die Gr\"o{\ss}e $t=\bar x/(\sigma_x/\sqrt{m}$ -(Standardabweichung $\sigma_x$) und vergleiche diese mit der Normalverteilung mit Standardabweichung Eins. Ist $t$ normalverteilt, bzw. unter welchen Bedingungen ist $t$ Normalverteilt? +(Standardabweichung $\sigma_x$) und vergleiche diese mit der Normalverteilung mit Standardabweichung Eins. Ist $t$ normalverteilt, bzw. unter welchen Bedingungen ist $t$ normalverteilt? \end{parts} diff --git a/statistics/code/tdistribution.m b/statistics/exercises/tdistribution.m similarity index 100% rename from statistics/code/tdistribution.m rename to statistics/exercises/tdistribution.m diff --git a/statistics/lecture/descriptivestatistics.tex b/statistics/lecture/descriptivestatistics.tex index ac99345..836a1d5 100644 --- a/statistics/lecture/descriptivestatistics.tex +++ b/statistics/lecture/descriptivestatistics.tex @@ -21,7 +21,7 @@ %%%%% section style %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \usepackage[sf,bf,it,big,clearempty]{titlesec} -\setcounter{secnumdepth}{-1} +\setcounter{secnumdepth}{1} %%%%% units %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -144,7 +144,7 @@ %%%%% equation references %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\newcommand{\eqref}[1]{(\ref{#1})} +%\newcommand{\eqref}[1]{(\ref{#1})} \newcommand{\eqn}{Eq.} \newcommand{\Eqn}{Eq.} \newcommand{\eqns}{Eqs.} @@ -229,7 +229,7 @@ \chapter{\tr{Descriptive statistics}{Deskriptive Statistik}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\section{Statistics of real-valued data} +%\section{Statistics of real-valued data} \begin{itemize} \item Location, central tendency @@ -259,7 +259,7 @@ \end{itemize} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\subsection{Median, Quartile, Percentile} +\section{\tr{Median, quartile, etc.}{Median, Quartil, etc.}} \begin{figure}[t] \includegraphics[width=1\textwidth]{median} @@ -307,7 +307,7 @@ {Schreibe eine Funktion, die das erste, zweite und dritte Quartil als Vektor zur\"uckgibt.} \end{exercise} -\subsection{Histogram} +\section{\tr{Histogram}{Histogramm}} Histogramme z\"ahlen die H\"aufigkeit $n_i$ des Auftretens von $N=\sum_{i=1}^M n_i$ Messwerten in $M$ Messbereichsklassen $i$ (Bins). @@ -349,7 +349,7 @@ des Auftretens der Gr\"o{\ss}e $x_i$ in der $i$-ten Klasse an \[ P_i = \frac{n_i}{N} = \frac{n_i}{\sum_{i=1}^M n_i} \; . \] -\subsection{Probability density function} +\section{\tr{Probability density function}{Wahrscheinlichkeitsdichte}} Meistens haben wir es jedoch mit reellen Messgr\"o{\ss}en zu tun. @@ -371,11 +371,14 @@ Meistens haben wir es jedoch mit reellen Messgr\"o{\ss}en zu tun. unterschiedliche Klassenbreiten vergleichbar.}} \end{figure} -Histogramme von reellen Messwerten m\"ussen auf das Integral 1 normiert werden, so dass -das Integral (nicht die Summe) \"uber das Histogramm eins ergibt. Das Integral -ist die Fl\"ache des Histograms. Diese setzt sich zusammen aus der Fl\"ache der einzelnen -Histogrammbalken. Diese haben die H\"ohe $n_i$ und die Breite $\Delta x$. Die Gesamtfl\"ache -$A$ des Histogramms ist also +Histogramme von reellen Messwerten m\"ussen auf das Integral 1 +normiert werden, so dass das Integral (nicht die Summe) \"uber das +Histogramm eins ergibt --- denn die Wahrscheinlichkeit, dass +irgendeiner der Messwerte auftritt mu{\ss} Eins sein. Das Integral ist +die Fl\"ache des Histogramms. Diese setzt sich zusammen aus der +Fl\"ache der einzelnen Histogrammbalken. Diese haben die H\"ohe $n_i$ +und die Breite $\Delta x$. Die Gesamtfl\"ache $A$ des Histogramms ist +also \[ A = \sum_{i=1}^N ( n_i \cdot \Delta x ) = \Delta x \sum_{i=1}^N n_i \] und das normierte Histogramm hat die H\"ohe \[ p(x_i) = \frac{n_i}{\Delta x \sum_{i=1}^N n_i} \] @@ -421,16 +424,17 @@ spricht von einer Wahrscheinlichkeitsdichte. \end{figure} -\subsection{Korrelation} +\section{\tr{Correlations}{Korrelationen}} \begin{figure}[t] \includegraphics[width=1\textwidth]{correlation} \caption{\label{correlationfig} Korrelationen zwischen zwei Datens\"atzen $x$ und $y$.} \end{figure} -Bisher haben wir Eigenschaften einer einzelnen Me{\ss}gr\"o{\ss}e angeschaut. -Bei mehreren Me{\ss}gr\"o{\ss}en, kann nach Abh\"angigkeiten gefragt werden. -Der Korrelationskoeffizient +Bisher haben wir Eigenschaften einer einzelnen Me{\ss}gr\"o{\ss}e +angeschaut. Bei mehreren Me{\ss}gr\"o{\ss}en, kann nach +Abh\"angigkeiten zwischen den beiden Gr\"o{\ss}en gefragt werden. Der +Korrelationskoeffizient \[ r_{x,y} = \frac{Cov(x,y)}{\sigma_x \sigma_y} = \frac{\langle (x-\langle x \rangle)(y-\langle y \rangle) \rangle}{\sqrt{\langle (x-\langle x \rangle)^2} \rangle \sqrt{\langle (y-\langle y @@ -452,9 +456,9 @@ Korrelationskoeffizienten nahe 0 (\figrefb{correlationfig}). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\subsection{Data types} +\section{Data types} -\subsubsection{Nominal scale} +\subsection{Nominal scale} \begin{itemize} \item Binary \begin{itemize} @@ -475,7 +479,7 @@ Korrelationskoeffizienten nahe 0 (\figrefb{correlationfig}). \item Statistics: mode, i.e. the most common item \end{itemize} -\subsubsection{Ordinal scale} +\subsection{Ordinal scale} \begin{itemize} \item Like nominal scale, but with an order \item Examples: ranks, ratings @@ -489,7 +493,7 @@ Korrelationskoeffizienten nahe 0 (\figrefb{correlationfig}). \item Statistics: mode, median \end{itemize} -\subsubsection{Interval scale} +\subsection{Interval scale} \begin{itemize} \item Quantitative/metric values \item Reasonable measure of distance between values, but no absolute zero @@ -505,7 +509,7 @@ Korrelationskoeffizienten nahe 0 (\figrefb{correlationfig}). \end{itemize} \end{itemize} -\subsubsection{Absolute/ratio scale} +\subsection{Absolute/ratio scale} \begin{itemize} \item Like interval scale, but with absolute origin/zero \item Examples: @@ -524,7 +528,7 @@ Korrelationskoeffizienten nahe 0 (\figrefb{correlationfig}). \end{itemize} \end{itemize} -\subsubsection{Data types} +\subsection{Data types} \begin{itemize} \item Data type selects \begin{itemize} @@ -539,7 +543,7 @@ Korrelationskoeffizienten nahe 0 (\figrefb{correlationfig}). categories ``small/medium/large'' (ordinal scale) \end{itemize} -\subsubsection{Examples from neuroscience} +\subsection{Examples from neuroscience} \begin{itemize} \item {\bf absolute:} \begin{itemize} @@ -615,7 +619,7 @@ aus der Stichprobe. Das hat mehrere Vorteile: \section{Bootstrap des Standardfehlers} -Beim Bootstrap erzeugen wir durch resampling neue Stichproben und +Beim Bootstrap erzeugen wir durch Resampling neue Stichproben und benutzen diese um die Stichprobenverteilung einer Statistik zu berechnen. Die Bootstrap Stichproben haben jeweils den gleichen Umfang wie die urspr\"unglich gemessene Stichprobe und werden durch Ziehen @@ -639,7 +643,7 @@ Stichprobe vorkommen. \end{document} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\subsection{Statistics} +\section{Statistics} What is "a statistic"? % dt. Sch\"atzfunktion \begin{definition}[statistic] A statistic (singular) is a single measure of some attribute of a