figure(1);

set(gcf, 'PaperUnits', 'centimeters');
xSize = 20; ySize = 15;
xLeft = (21 - xSize)/2; yTop = (30 - ySize)/2;
set(gcf,'PaperPosition', [xLeft yTop xSize ySize]);
set(gcf,'Position',[0 0 xSize*50 ySize*50]);

hold on;

t = title('Maximum-Likelihood-Sch\"atzer f\"ur Exponentialpopulation', 'interpreter', 'latex');
set(t, 'FontSize', 16);
 
xlabel('x');
ylabel('y');

f_lambda = @(x, lambda) lambda*exp(-lambda*x);

x = 0:0.1:4;

N = 100;

lambda = 2;

X = exprnd(1/lambda, [N, 1]);

lambda_hat = 1/mean(X);

y    = f_lambda(x, lambda);
yhat = f_lambda(x, lambda_hat);

hold on;
plot(x, y,    'b');
plot(x, yhat, 'g');
plot(X, 0, 'r.');

axis([0 5 0 max([y yhat]) + 1]);

l = legend('Exponentialdichte $f_{\lambda}$', ...
           ['Gesch\"atzte Dichte $f_{\hat{\lambda}}$, $\hat{\lambda} = ', num2str(lambda_hat), '$'], ...
           ['Stichprobe von $N = ', num2str(N), '$ IID Zufallszahlen aus $\mathrm{Exp}(', num2str(lambda), ')$']);
set(l, 'Interpreter', 'latex', 'FontSize', 15, 'Location', 'NorthWest');