%% Load data and make variables

load('../Data/KjonnOgHoyde.mat')

kjonn=KjonnOgHoyde(:,1);
hogde=KjonnOgHoyde(:,2);


% Make vectors with hight of men and women

indexMann=find(kjonn==0);
indexKvinne=find(kjonn==1);
hogdeMann=hogde(indexMann);
hogdeKvinne=hogde(indexKvinne);

antkvinner=length(indexKvinne)
antmenn=length(indexMann)



%% Hypotesetest H0 sigma^2=sigma02=6.5^2 mot H1 mu!=6^2,  N=antkvinner, alpha=0.05
N=antkvinner
alpha=0.05
sigma02=6.0^2
%Estimert varians
s2=var(hogdeKvinne)
std(hogdeKvinne)


%% Som x2-observator
ourX2=(N-1)*s2/sigma02
cutoffX2Upper=chi2inv(1-alpha, N-1)
cutoffX2Lower=chi2inv(alpha, N-1)

%% Paa varians-skala
Lower=cutoffX2Lower*sigma02/(N-1)
Upper=cutoffX2Upper*sigma02/(N-1)

%% For standardavvik

sqrt(Lower)
sqrt(Upper)

%%Metode p-verdi

pverdiEiSide=1-chi2cdf(ourX2,N-1)
