2007年4月10日火曜日

対応ありのt検定:2 標本の平均値の差の検定

%MATLABの場合
echo on
N = 20;
x = rand(N,1); % 標本1の一様分布の擬似乱数
x_mea = mean(x); % 標本1の平均値
disp(x_mea);
0.5653
x_std = std(x); % 標本1の不偏標準偏差
disp(x_std);
0.2773
y = rand(N,1); % 標本2の一様分布の擬似乱数
y_mea = mean(y); % 標本2の平均値
disp(y_mea);
0.4351
y_std = std(y); % 標本2の不偏標準偏差
disp(y_std);
0.1968
d = x - y;
d_mea = mean(d);
disp(d_mea);
0.1301
%帰無仮説: x_mea(標本1の平均値)は,y_mea(標本1の平均値)である
%対立仮説: x_mea(標本1の平均値)は,y_mea(標本1の平均値)ではない
%両側5%有意水準でttestを実行する
[h,p,ci,stats] = ttest(d,0); %1標本と対標本T-検定
str = sprintf('h = %1.2f, p = %f, ci = [%f,%f]',h,p,ci(1),ci(2));
%h = 0 -> 帰無仮説は、棄却しない。つまり、x_mea(標本1の平均値)は,x_mea(標本2の平均値)である
disp(str);
h = 0.00, p = 0.120141, ci = [-0.037243,0.297517]
disp(stats);
tstat: 1.6273
df: 19
sd: 0.3576

0 件のコメント: