
% Noun First Example
disp('Noun First Example')
nounfirst =[12 21 12 16 20 39 26 29 30 35 38 34]; 
    %sample 1 form N(mu1, sigma)
nounlast =[10 12 23 14 16 8 16 22 32 13 32 35]; 
    %sample 2 from N(mu2, sigma)
d=nounfirst - nounlast;
dbar = mean(d)
%dbar = 6.5833
sd = std(d)
%sd = 11.0409
n = length(d)
%n = 12
t = dbar/(sd/sqrt(n))
%t = 2.0655

%p-value for 2-sided test
pval2s = 2* (1-tcdf(t, n-1))
pval2s = 2 * tcdf(-abs(t), n-1)
%pval = 0.0633

%If the alternative is one sided,  
% mu(nf) > mu(nl)
pval1s =1-tcdf(t, n-1)
%pval =  0.0316


