theta = 3;
x = -5:0.1:11;
plot(x,normpdf(x,theta));
hold on
c=3;
pd2 = makedist('Uniform','lower',theta-c,'upper',theta+c);
pdf2 = pdf(pd2,x);
plot(x,pdf2,'g');
hold on
plot(x,1./(pi*(1+(x-theta).*(x-theta))),'r');

%Simuler data fra ulike fordelingner, ulike estimatorer
theta = 3;sigma = 1;
M = 10000;
n = 20;
%X = normrnd(theta,sigma,n,M);                 % Normal variables
%X = theta + sigma*sqrt(12)*(rand(n,M)-0.5);    % Uniform variables
X = theta + tan(pi*(rand(n,M)-0.5));         % Cauchy variables
Xbar = mean(X);
Xtilde = median(X);
Xtr = trimmean(X,20);
Xbare = 0.5*(min(X)+max(X));
subplot(2,2,1)
hist(Xbar);
%axis([0 5 0 5000])
title('Gjennomsnitt');
subplot(2,2,2)
hist(Xtilde);
title('Median');
%axis([0 5 0 5000])
subplot(2,2,3)
hist(Xtr);
title('Trimmet gjennomsnitt')
%axis([0 5 0 5000])
subplot(2,2,4)
hist(Xbare);
title('Gjennomsnitt av ekstremer');
%axis([0 5 0 5000])
