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-Likelyhood-Sch\"atzer', 'interpreter', 'latex');
set(t, 'FontSize', 16);
 
xlabel('x');
ylabel('y');

phi = @(x, mu, sigma) (2*pi)^0.5/sigma*exp(-(x - mu).^2/(2*sigma^2));

x = -4.5:0.1:4.5;

N = 100;

X = randn(N, 1);

mu = mean(X);
sigma = mean((X - mu).^2);

y    = phi(x, 0, 1);
yhat = phi(x, mu, sigma);

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

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

l = legend('Standardnormaldichte $\varphi(x; 0, 1)$', ...
           ['Gesch\"atzte Dichte $\varphi(x; \hat{\mu}, \hat{\sigma}), \hat{\mu} = ', num2str(mu), ', \hat{\sigma} = ', num2str(sigma), '$'], ...
           ['IID Stichprobe von $N = ', num2str(N), '$ Zufallszahlen aus $\mathcal{N}(0, 1)$']);
set(l, 'Interpreter', 'latex', 'FontSize', 15, 'Location', 'NorthWest');