% H?yder fra http://www.math.hope.edu/swanson/data/heights.txt
height = load('height.txt');
gHeight = height(1:50, 2)*0.0254;
bHeight = height(51:100, 2)*0.0254;

% Kroppstemperaturer fra http://www.math.hope.edu/swanson/data/body_temp.txt
bTmp = load('bodyTmp.txt');
gTmp = (bTmp(1:65, 1)-32)*5/9;
bTmp = (bTmp(66:130, 1)-32)*5/9;

% Kryssplott for h?yde
scatter(ones(50,1), gHeight, 120, 'LineWidth', 3);
hold on;
scatter(2*ones(50,1), bHeight, 120, 'LineWidth', 3);
title('Kryssplott for h\oyde', 'FontSize', 30, 'interpreter', 'tex');
ylabel('H\oyde (m)', 'FontSize', 27, 'interpreter', 'tex');
xlabel('Kj\onn', 'FontSize', 27, 'interpreter', 'tex');
set(gca, 'FontSize', 27);
xlim([0.5, 2.5])

% Kryssplott for kroppstemperatur
scatter(ones(65,1), gTmp, 120, 'LineWidth', 3);
hold on;
scatter(2*ones(65,1), bTmp, 120, 'LineWidth', 3);
title('Kryssplott for kroppstemperatur', 'FontSize', 30);
ylabel('Kroppstemperatur (C)', 'FontSize', 27);
xlabel('Kj\onn', 'FontSize', 27, 'interpreter', 'tex');
set(gca, 'FontSize', 27);
xlim([0.5, 2.5])

% Empirisk middelverdi
mgH = mean(gHeight)
mbH = mean(bHeight)
mgT = mean(gTmp)
mbT = mean(bTmp)

% Empirisk median
megH = median(gHeight)
mebH = median(bHeight)
megT = median(gTmp)
mebT = median(bTmp)

% Kryssplott for h?yde med middelverdi markert
scatter(ones(50,1), gHeight, 120, 'LineWidth', 3);
hold on;
scatter(2*ones(50,1), bHeight, 120, 'LineWidth', 3);
plot([-1, 4], [mgH mgH], 'b', 'LineWidth', 3);
plot([-1, 4], [mbH mbH], 'r', 'LineWidth', 3);
title('Kryssplott for h\oyde', 'FontSize', 30, 'interpreter', 'tex');
ylabel('H\oyde (m)', 'FontSize', 27, 'interpreter', 'tex');
xlabel('Kj\onn', 'FontSize', 27, 'interpreter', 'tex');
set(gca, 'FontSize', 27);
xlim([0.5, 2.5])

% Kryssplott for kroppstemperatur med mean
scatter(ones(65,1), gTmp, 120, 'LineWidth', 3);
hold on;
scatter(2*ones(65,1), bTmp, 120, 'LineWidth', 3);
plot([-1, 4], [mgT mgT], 'b', 'LineWidth', 3);
plot([-1, 4], [mbT mbT], 'r', 'LineWidth', 3);
title('Kryssplott for kroppstemperatur', 'FontSize', 30);
ylabel('Kroppstemperatur (C)', 'FontSize', 27);
xlabel('Kj\onn', 'FontSize', 27, 'interpreter', 'tex');
set(gca, 'FontSize', 27);
xlim([0.5, 2.5])

% Empirisk standardavvik
sgH = std(gHeight)
sbH = std(bHeight)
sgT = std(gTmp)
sbT = std(bTmp)

% Kryssplott for h?yde med middelverdi markert
scatter(ones(50,1), gHeight, 120, 'LineWidth', 3);
hold on;
scatter(2*ones(50,1), bHeight, 120, 'LineWidth', 3);
plot([-1, 4], [mgH mgH], 'b', 'LineWidth', 3);
plot([-1, 4], [mgH+sgH mgH+sgH], 'b-.', 'LineWidth', 3);
plot([-1, 4], [mgH-sgH mgH-sgH], 'b-.', 'LineWidth', 3);
plot([-1, 4], [mbH mbH], 'r', 'LineWidth', 3);
plot([-1, 4], [mbH+sbH mbH+sbH], 'r-.', 'LineWidth', 3);
plot([-1, 4], [mbH-sbH mbH-sbH], 'r-.', 'LineWidth', 3);
title('Kryssplott for h\oyde', 'FontSize', 30, 'interpreter', 'tex');
ylabel('H\oyde (m)', 'FontSize', 27, 'interpreter', 'tex');
xlabel('Kj\onn', 'FontSize', 27, 'interpreter', 'tex');
set(gca, 'FontSize', 27);
xlim([0.5, 2.5])

% Kryssplott for kroppstemperatur med mean
scatter(ones(65,1), gTmp, 120, 'LineWidth', 3);
hold on;
scatter(2*ones(65,1), bTmp, 120, 'LineWidth', 3);
plot([-1, 4], [mgT mgT], 'b', 'LineWidth', 3);
plot([-1, 4], [mgT+sgT mgT+sgT], 'b-.', 'LineWidth', 3);
plot([-1, 4], [mgT-sgT mgT-sgT], 'b-.', 'LineWidth', 3);
plot([-1, 4], [mbT mbT], 'r', 'LineWidth', 3);
plot([-1, 4], [mbT+sbT mbT+sbT], 'r', 'LineWidth', 3);
plot([-1, 4], [mbT-sbT mbT-sbT], 'r', 'LineWidth', 3);
title('Kryssplott for kroppstemperatur', 'FontSize', 30);
ylabel('Kroppstemperatur (C)', 'FontSize', 27);
xlabel('Kj\onn', 'FontSize', 27, 'interpreter', 'tex');
set(gca, 'FontSize', 27);
xlim([0.5, 2.5])

% Boksplott
bpH = boxplot([gHeight bHeight]);
title('Boksplott for h\oyde', 'FontSize', 30, 'interpreter', 'tex');
ylabel('H\oyde (m)', 'FontSize', 27, 'interpreter', 'tex');
xlabel('Kj\onn', 'FontSize', 27, 'interpreter', 'tex');
set(gca, 'FontSize', 27)
set(bpH(:,:),'linewidth',3);

bpT = boxplot([gTmp bTmp]);
title('Boksplott for kroppstemperatur', 'FontSize', 30, 'interpreter', 'tex');
ylabel('Kroppstemperatur (C)', 'FontSize', 27, 'interpreter', 'tex');
xlabel('Kj\onn', 'FontSize', 27, 'interpreter', 'tex');
set(gca, 'FontSize', 27)
set(bpT(:,:),'linewidth',3);

% Histogram
nInt = 10;
y = bHeight;
intW = (max(y)-min(y))/nInt;
x = min(y):intW:max(y);
ncount = histc(y, x);
relF = ncount/length(y);
bar(x-intW/2, relF, 1);
xlim([min(x), max(x)]);
set(gca, 'FontSize', 27);
title('H\oyde av menn', 'FontSize', 30, 'interpreter', 'tex');
xlabel('H\oyde (m)', 'FontSize', 27, 'interpreter', 'tex');
ylabel('Relativ frekvens', 'FontSize', 27);
