
% A sample of 11 Classical Neanderthal European skull capacities
% gave the sample variance of 11175, n2=4 middle eastern 
% skulls produced the sample variance of 741. 
%  Assuming the measurements are normally distributed 
%test the hypothesis that the population variances are the same 
%against the two sided alternative. Use alpha=0.05.

s12 = 11175; s22=741;
n1=11; n2=4;
% 
f = s12/s22  %15.0810
% since s12 > s22 -> f > 1 and critical
%region is the upper tail of F-distribution with
%n1-1, n2-1 degrees of freedom


crit = finv(0.975, n1-1, n2-1)    %14.4189 critical val
% compare this critical point with f

pval = 2*min(fcdf(f, n1-1,  n2 -1),    1-fcdf(f, n1-1,  n2 -1)) 
%0.0469 p-value
% 
%
%------------------
% one sided
pval = 1-fcdf(f, n1-1, n2-1)
%%
% suppose that we took statistics ff=s22/s12 instead of
% f=s12/s22.
ff=1/f  %0.0663 s22/s12


pval = 2*min(fcdf(ff, n2-1, n1-1), 1-fcdf(ff, n2-1, n1-1) ) %p value
%

critnew = finv(0.05, n2-1, n1-1) %critical pt
critold = 1/critnew  % test for consistency
% this reciprocal should be equal to critical point for
% f=1/ff.

