[likelihood] fixed plots for exercise

This commit is contained in:
Jan Benda 2018-12-18 09:59:03 +01:00
parent deed303596
commit 0cd4165858
5 changed files with 16 additions and 4 deletions

View File

@ -107,7 +107,15 @@ of the standard deviation.
\end{parts}
\begin{solution}
\lstinputlisting{mlestd.m}
\includegraphics[width=1\textwidth]{mlestd}
\includegraphics[width=1\textwidth]{mlestd}\\
The more data the smaller the product of the probabilities ($\approx
p^n$ with $0 \le p < 1$) and the smaller the sum of the logarithms
of the probabilities ($\approx n\log p$, note that $\log p < 0$).
The product eventually gets smaller than the precision of the
floating point numbers support. Therefore for $n=1000$ the products
becomes zero. Using the logarithm avoids this numerical problem.
\end{solution}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -151,7 +159,10 @@ standard deviation $\sigma_i$:
\end{parts}
\begin{solution}
\lstinputlisting{mlepropest.m}
\includegraphics[width=1\textwidth]{mlepropest}
\includegraphics[width=1\textwidth]{mlepropest}\\
The estimated slopes are centered around the true slope. The
standard deviation of the estimated slopes gets smaller for larger
$n$ and less noise in the data.
\end{solution}
\continue

View File

@ -18,8 +18,9 @@ for i = 1:length(sigmas)
subplot(2, 2, 2*(i-1)+j);
bins = [1.9:0.005:2.1];
hist(slopes, bins);
xlabel('estimated slope');
title(sprintf('sigma=%g, n=%d', sigma, n));
end
end
savefigpdf(gcf, 'mlepropest.pdf', 12, 7);
savefigpdf(gcf, 'mlepropest.pdf', 15, 10);

Binary file not shown.

View File

@ -32,4 +32,4 @@ for k = 1:length(ns)
xlabel('standard deviation')
ylabel('log likelihood')
end
savefigpdf(gcf, 'mlestd.pdf', 15, 5);
savefigpdf(gcf, 'mlestd.pdf', 15, 10);

Binary file not shown.