
%MOON ILLUSION
x = [1.73, 1.06, 2.03, 1.40, 0.95, 1.13, 1.41, 1.73, 1.63, 1.56];
n=length(x); 


%TEST H_0: mu=1 AGAINST ONE SIDED ALTERNATIVE H_1: mu>1.
t = (mean(x)-1)/(std(x)/sqrt(n))
% t= 4.2976
crit = tinv(1-0.05, n-1)
% crit=1.8331. RR = (1.8331, infinity)
pval = 1-tcdf(t, n-1)
% pval = 9.9885e-004


% POWER AGAINST ALTERNATIVE H_1: mu = 1.3
 mu0 = 1;  mu1= 1.3; alpha=0.05;
pow0 = 1-normcdf( norminv(1-alpha) - (mu1-mu0)*sqrt(n)/std(x) )
    %pow0 = 0.8728
pow1 = 1- nctcdf( tinv(1-alpha, n-1), n-1,(mu1-mu0)*sqrt(n)/std(x))
    %pow1 =0.8217
pow2 =  1-normcdf((tinv(1-alpha,n-1)- ...
(mu1-mu0)/std(x) * sqrt(n))/sqrt(1 + (tinv(1-alpha,n-1))^2/(2*n-2)))
    %pow2 = 0.8088

