reorganized statistics exercises

This commit is contained in:
2016-11-15 15:53:12 +01:00
parent bd62a15593
commit 778fde35fa
34 changed files with 214 additions and 3 deletions

View File

@@ -0,0 +1,34 @@
TEXFILES=$(wildcard exercises??.tex)
EXERCISES=$(TEXFILES:.tex=.pdf)
SOLUTIONS=$(EXERCISES:exercises%=solutions%)
.PHONY: pdf exercises solutions watch watchexercises watchsolutions clean
pdf : $(SOLUTIONS) $(EXERCISES)
exercises : $(EXERCISES)
solutions : $(SOLUTIONS)
$(SOLUTIONS) : solutions%.pdf : exercises%.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)

Binary file not shown.

View File

@@ -0,0 +1,17 @@
function [bootsem, mu] = bootstrapmean( x, resample )
% computes standard error by bootstrapping the data
% x: vector with data
% resample: number of resamplings
% returns:
% bootsem: the standard error of the mean
% mu: the bootstrapped means as a vector
mu = zeros( resample, 1 );
nsamples = length(x);
for i = 1:resample
% resample:
xr = x(randi(nsamples, nsamples, 1));
% compute statistics on sample:
mu(i) = mean(xr);
end
bootsem = std( mu );
end

View File

@@ -0,0 +1,92 @@
%PDF-1.4
%Çì<C387>¢
5 0 obj
<</Length 6 0 R/Filter /FlateDecode>>
stream
xœÅWÛn1 }ÏWÌ# 1$“ë¼"!žË¬Ä¬è¢jSÔ‚Ï'lj=»Õö‰^”Ø>ëãÄ'iú4ÉYM2ÃxŒâÃ?<3F>~
jzH¿Ÿ…6ë¬\˜´\f;E´•VzÖz: e<>åfEŸÙ§ÏbòBNòmG9ÅvCUÛ˜õ† Wjx‰àF«këè©fçaCNâI¨Ò‰ †cœ>R7r™÷¢6H¥Ì³
z™”;¢x#ßħƒ¸«q³ªAªiv¯¦{z5·VÂP„íUì7½ñ“`C^ϬŒIÉ;¹<C2B9>}×'ç¼_½¯¬><3E>'=zk
MHyÓòH;Ѫ2Ì9Úëh¬¤C ñÚj¼Mæ--ÙU3¨ªÙ–±;¥šqsBUæ[ܼ*=ºÚ¢ÿqöŸ^8šEYÚ§ žžë»ø:=ŠzZ—ù|fUÃA\ò3éèJ]ûüMÜ¿c˜ˆ¶“¶´æ,¬ªBØ{ÚfÑy]QÄi×Ô¯Š«ÌÑ6Ò”õ'Sg{Ocâ•l ±Ôe£$ÁDéeOÅRoCÒÐ<C392>ëášhØŸµÎö$ˆ7]ê]¸¨ ¢meNàìçHÃh7¿¸ªÁêëp†k¡y-`cñ¦ ŸNC•Ðì~9oÈEÖ=Èk¸(¢©ßI7h<37>b"Ú«\Aq^Ö+jïAfÏ…Cj¯ÌÑNg$O2aïiL¼<C2BC>! Á«jú§áØ)m¹l©‰tŒ~#q °O@hG5AöôUÿÔz_wdïAJKÕDãXÏ(`
‰hwÉi™…tž¨Ga}ã±ìÁXæõ-‡ÃÙ¬r¤ÛX´)¥7ŒÆ#ÚØ¡`Yù4×EÀ²¨8)$v”b¥•ÌFRË•2Æ»®‡“8"XýÞo§oïAÊ@•Bã°JJI!ñ‰¶Ìjœ~¢@fdÓIÅ2÷Ò×$ðüá6h²"wI+£)"¢]•¸†ºïÔB®Ý•"Úý9¬*°g>Øm5i³ËÛ„ÛȸHîn~Ú­ðïÇÒ_½óÃ.ÇÞ§Ÿ4ªúun Ç¿áûïNü­Ôlendstream
endobj
6 0 obj
824
endobj
4 0 obj
<</Type/Page/MediaBox [0 0 170 142]
/Rotate 0/Parent 3 0 R
/Resources<</ProcSet[/PDF /Text]
/ExtGState 9 0 R
/Font 10 0 R
>>
/Contents 5 0 R
>>
endobj
3 0 obj
<< /Type /Pages /Kids [
4 0 R
] /Count 1
>>
endobj
1 0 obj
<</Type /Catalog /Pages 3 0 R
/Metadata 11 0 R
>>
endobj
7 0 obj
<</Type/ExtGState
/OPM 1>>endobj
9 0 obj
<</R7
7 0 R>>
endobj
10 0 obj
<</R8
8 0 R>>
endobj
8 0 obj
<</BaseFont/Helvetica/Type/Font
/Subtype/Type1>>
endobj
11 0 obj
<</Length 1316>>stream
<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
<?adobe-xap-filters esc="CRLF"?>
<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='XMP toolkit 2.9.1-13, framework 1.6'>
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#' xmlns:iX='http://ns.adobe.com/iX/1.0/'>
<rdf:Description rdf:about='94827694-b0d9-11f0-0000-86f60cc553dd' xmlns:pdf='http://ns.adobe.com/pdf/1.3/' pdf:Producer='Artifex Ghostscript 8.54'/>
<rdf:Description rdf:about='94827694-b0d9-11f0-0000-86f60cc553dd' xmlns:xap='http://ns.adobe.com/xap/1.0/' xap:ModifyDate='2015-10-22' xap:CreateDate='2015-10-22'><xap:CreatorTool>Artifex Ghostscript 8.54 PDF Writer</xap:CreatorTool></rdf:Description>
<rdf:Description rdf:about='94827694-b0d9-11f0-0000-86f60cc553dd' xmlns:xapMM='http://ns.adobe.com/xap/1.0/mm/' xapMM:DocumentID='94827694-b0d9-11f0-0000-86f60cc553dd'/>
<rdf:Description rdf:about='94827694-b0d9-11f0-0000-86f60cc553dd' xmlns:dc='http://purl.org/dc/elements/1.1/' dc:format='application/pdf'><dc:title><rdf:Alt><rdf:li xml:lang='x-default'>/tmp/tpd0b45dc9_ff5a_4aa8_90bd_50aa8e8237b6.ps</rdf:li></rdf:Alt></dc:title></rdf:Description>
</rdf:RDF>
</x:xmpmeta>
<?xpacket end='w'?>
endstream
endobj
2 0 obj
<</Producer(Artifex Ghostscript 8.54)
/CreationDate(D:20151022150138)
/ModDate(D:20151022150138)
/Creator(MATLAB, The MathWorks, Inc. Version 8.3.0.532 \(R2014a\). Operating System: Linux 3.13.0-24-generic #47-Ubuntu SMP Fri May 2 23:30:00 UTC 2014 x86_64.)
/Title(/tmp/tpd0b45dc9_ff5a_4aa8_90bd_50aa8e8237b6.ps)>>endobj
xref
0 12
0000000000 65535 f
0000001146 00000 n
0000002741 00000 n
0000001087 00000 n
0000000928 00000 n
0000000015 00000 n
0000000909 00000 n
0000001211 00000 n
0000001311 00000 n
0000001252 00000 n
0000001281 00000 n
0000001375 00000 n
trailer
<< /Size 12 /Root 1 0 R /Info 2 0 R
/ID [<8FE161FFCC6D1C11BAD3CE59BA0E3F32><8FE161FFCC6D1C11BAD3CE59BA0E3F32>]
>>
startxref

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,47 @@
%% (b) load the data:
load( 'thymusglandweights.dat' );
nsamples = 80;
x = thymusglandweights(1:nsamples);
%% (c) mean, sem and hist:
sem = std(x)/sqrt(nsamples);
fprintf( 'Mean of the data set = %.2fmg\n', mean(x) );
fprintf( 'SEM of the data set = %.2fmg\n', sem );
hist(x,20)
xlabel('x')
ylabel('count')
savefigpdf( gcf, 'bootstraptymus-datahist.pdf', 6, 5 );
pause( 2.0 )
%% (d) bootstrap the mean:
resample = 500;
[bootsem, mu] = bootstrapmean( x, resample );
hist( mu, 20 );
xlabel('mean(x)')
ylabel('count')
savefigpdf( gcf, 'bootstraptymus-meanhist.pdf', 6, 5 );
fprintf( ' bootstrap standard error: %.3f\n', bootsem );
fprintf( 'theoretical standard error: %.3f\n', sem );
%% (e) confidence interval:
q = quantile(mu, [0.025, 0.975]);
fprintf( '95%% confidence interval of the mean from %.2fmg to %.2fmg\n', q(1), q(2) );
pause( 2.0 )
%% (f): dependence on sample size:
nsamplesrange = 10:10:1000;
bootsems = zeros( length(nsamplesrange),1);
for n=1:length(nsamplesrange)
nsamples = nsamplesrange(n);
% [bootsems(n), mu] = bootstrapmean(x, resample);
bootsems(n) = bootstrapmean(thymusglandweights(1:nsamples), resample);
end
plot(nsamplesrange, bootsems, 'b', 'linewidth', 2);
hold on
plot(nsamplesrange, std(x)./sqrt(nsamplesrange), 'r', 'linewidth', 1)
hold off
xlabel('sample size')
ylabel('SEM')
legend('bootsrap', 'theory')
savefigpdf( gcf, 'bootstraptymus-samples.pdf', 6, 5 );

View File

@@ -0,0 +1,58 @@
%% (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);
plot(x, a*x, 'r', 'linewidth', 3 );
hold on
%scatter(x, y ); % either scatter ...
plot(x, y, 'o', 'markersize', 2 ); % ... or plot - same plot.
xlim([-4 4])
ylim([-4 4])
xlabel('x')
ylabel('y')
hold off
%% (d) correlation coefficient:
%c = corrcoef(x, y); % returns correlation matrix
%rd = c(1, 2);
rd = corr(x, y);
fprintf('correlation coefficient = %.2f\n', rd );
%% (e) 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);
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 );
xlim([-0.2 0.2])
xlabel('Correlation coefficient');
ylabel('Probability density of H0');
hold off;
savefigpdf( gcf, 'correlationsignificance.pdf', 12, 6 );

Binary file not shown.

View File

@@ -0,0 +1,163 @@
\documentclass[12pt,a4paper,pdftex]{exam}
\usepackage[german]{babel}
\usepackage{pslatex}
\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}
%%%%% layout %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[left=20mm,right=20mm,top=25mm,bottom=25mm]{geometry}
\pagestyle{headandfoot}
\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}{}
\setlength{\baselineskip}{15pt}
\setlength{\parindent}{0.0cm}
\setlength{\parskip}{0.3cm}
\renewcommand{\baselinestretch}{1.15}
%%%%% 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%
\fi}
\newcommand{\continuepage}{\ifprintanswers%
\newpage
\else
\vfill\hspace*{\fill}$\rightarrow$\newpage%
\fi}
\newcommand{\newsolutionpage}{\ifprintanswers%
\newpage%
\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}
\input{instructions}
\begin{questions}
\question \qt{Bootstrap des Standardfehlers}
\begin{parts}
\part Lade von Ilias die Datei \code{thymusglandweights.dat} herunter.
Darin befindet sich ein Datensatz vom Gewicht der Thymus Dr\"use in 14-Tage alten
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 das 95\,\% Konfidenzintervall f\"ur den Mittelwert
aus der Bootstrap Verteilung (\code{quantile()} Funktion) --- also
das Interval innerhalb dessen mit 95\,\% Wahrscheinlichkeit der
wahre Mittelwert liegen wird.
\part Benutze den ganzen Datensatz und die Bootstrapping Technik, um die Abh\"angigkeit
des Standardfehlers von der Stichprobengr\"o{\ss}e zu bestimmen.
\part Vergleiche mit der bekannten Formel f\"ur den Standardfehler $\sigma/\sqrt{n}$.
\end{parts}
\begin{solution}
\lstinputlisting{bootstrapmean.m}
\lstinputlisting{bootstraptymus.m}
\includegraphics[width=0.5\textwidth]{bootstraptymus-datahist}
\includegraphics[width=0.5\textwidth]{bootstraptymus-meanhist}
\includegraphics[width=0.5\textwidth]{bootstraptymus-samples}
\end{solution}
\continue
\question \qt{Student t-Verteilung}
\begin{parts}
\part Erzeuge 100000 normalverteilte Zufallszahlen.
\part Ziehe daraus 1000 Stichproben vom Umfang $m=3$, 5, 10, oder 50.
\part Berechne den Mittelwert $\bar x$ der Stichproben und plotte die Wahrscheinlichkeitsdichte
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?
\end{parts}
\begin{solution}
\lstinputlisting{tdistribution.m}
\includegraphics[width=1\textwidth]{tdistribution-n03}\\
\includegraphics[width=1\textwidth]{tdistribution-n05}\\
\includegraphics[width=1\textwidth]{tdistribution-n10}\\
\includegraphics[width=1\textwidth]{tdistribution-n50}
\end{solution}
\question \qt{Korrelationen}
\begin{parts}
\part Erzeuge 1000 korrelierte Zufallszahlen $x$, $y$ durch
\begin{verbatim}
n = 1000
a = 0.2;
x = randn(n, 1);
y = randn(n, 1) + a*x;
\end{verbatim}
\part Erstelle einen Scatterplot der beiden Variablen.
\part Warum ist $y$ mit $x$ korreliert?
\part Berechne den Korrelationskoeffizienten zwischen $x$ und $y$.
\part Was m\"usste man tun, um die Korrelationen zwischen den $x$-$y$
Paaren zu zerst\"oren?
\part Mach genau dies 1000 mal und berechne jedes Mal den Korrelationskoeffizienten.
\part Bestimme die Wahrscheinlichkeitsdichte dieser Korrelationskoeffizienten.
\part Ist die Korrelation der urspr\"unglichen Daten signifikant?
\part Variiere die Stichprobengr\"o{\ss}e \code{n} und \"uberpr\"ufe
auf gleiche Weise die Signifikanz.
\end{parts}
\begin{solution}
\lstinputlisting{correlationsignificance.m}
\includegraphics[width=1\textwidth]{correlationsignificance}
\end{solution}
\end{questions}
\end{document}

View File

@@ -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

View File

@@ -0,0 +1,28 @@
function savefigpdf( fig, name, width, height )
% Saves figure fig in pdf file name.pdf with appropriately set page size
% and fonts
% default width:
if nargin < 3
width = 11.7;
end
% default height:
if nargin < 4
height = 9.0;
end
% paper:
set( fig, 'PaperUnits', 'centimeters' );
set( fig, 'PaperSize', [width height] );
set( fig, 'PaperPosition', [0.0 0.0 width height] );
set( fig, 'Color', 'white')
% font:
set( findall( fig, 'type', 'axes' ), 'FontSize', 12 )
set( findall( fig, 'type', 'text' ), 'FontSize', 12 )
% save:
saveas( fig, name, 'pdf' )
end

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,58 @@
%% (a) generate random numbers:
n = 100000;
x=randn(n, 1);
for nsamples=[3 5 10 50]
nsamples
%% compute mean, standard deviation and t:
nmeans = 10000;
means = zeros( nmeans, 1 );
sdevs = zeros( nmeans, 1 );
students = zeros( nmeans, 1 );
for i=1:nmeans
sample = x(randi(n, nsamples, 1));
means(i) = mean(sample);
sdevs(i) = std(sample);
students(i) = mean(sample)/std(sample)*sqrt(nsamples);
end
% Gaussian pdfs:
msdev = std(means);
tsdev = 1.0;
dxg=0.01;
xmax = 10.0;
xmin = -xmax;
xg = [xmin:dxg:xmax];
pm = exp(-0.5*(xg/msdev).^2)/sqrt(2.0*pi)/msdev;
pt = exp(-0.5*(xg/tsdev).^2)/sqrt(2.0*pi)/tsdev;
%% plots
subplot(1, 2, 1)
bins = xmin:0.2:xmax;
[h,b] = hist(means, bins);
h = h/sum(h)/(b(2)-b(1));
bar(b, h, 'facecolor', 'b', 'edgecolor', 'b')
hold on
plot(xg, pm, 'r', 'linewidth', 2)
title( sprintf('sample size = %d', nsamples) );
xlim( [-3, 3] );
xlabel('Mean');
ylabel('pdf');
hold off;
subplot(1, 2, 2)
bins = xmin:0.5:xmax;
[h,b] = hist(students, bins);
h = h/sum(h)/(b(2)-b(1));
bar(b, h, 'facecolor', 'b', 'edgecolor', 'b')
hold on
plot(xg, pt, 'r', 'linewidth', 2)
title( sprintf('sample size = %d', nsamples) );
xlim( [-8, 8] );
xlabel('Student-t');
ylabel('pdf');
hold off;
savefigpdf( gcf, sprintf('tdistribution-n%02d.pdf', nsamples), 14, 5 );
pause( 3.0 )
end

File diff suppressed because it is too large Load Diff