%% testing ttest2
%
clear
clc
format compact
mu1 = 5.7500;
mu2 = 2.3972;
sd1 = 3.8750;
sd2 = 1.8557;
n1 = 10;
n2 = 12;
x1 = fake_data(mu1, sd1, n1);
x2 = fake_data(mu2, sd2, n2);
alpha=0.05;
disp('diff = 0')
% perform two-tail test H0: u1=u2 or H0: u1-u2=0
[H,P,CI,STATS] = ttest2(x1,x2,alpha,'both','unequal')
% perform right-tail test H0: u1-u2=0 v H1: u1-u2>0
[H,P,CI,STATS] = ttest2(x1,x2,alpha,'right','unequal')
% perform left-tail test H0: u1-u2=0 v H1: u1-u2<0
[H,P,CI,STATS] = ttest2(x1,x2,alpha,'left','unequal')

% testing diff=2;
diff=2;
disp('diff = 2')
% perform two-tail test H0: u1-u2=diff or H0: u1-diff=u2
[H,P,CI,STATS] = ttest2(x1-diff,x2,alpha,'both','unequal')
% perform right-tail test H0: u1-u2=diff v H1: u1-u2>diff
[H,P,CI,STATS] = ttest2(x1-diff,x2,alpha,'right','unequal')
% perform left-tail test H0: u1-u2=diff v H1: u1-u2<diff
[H,P,CI,STATS] = ttest2(x1-diff,x2,alpha,'left','unequal')