Home > functions > tool_box > time_frequency > ttest_pair.m

ttest_pair

PURPOSE ^

[t,p,n]=ttest_pair(indat1,indat2); %tests if indat1 > indat2 tail 1=one tailed

SYNOPSIS ^

function [t,p,df]=ttest_pair(indat1,indat2,tail);

DESCRIPTION ^

 [t,p,n]=ttest_pair(indat1,indat2);  %tests if indat1 > indat2  tail 1=one tailed

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [t,p,df]=ttest_pair(indat1,indat2,tail);
0002 % [t,p,n]=ttest_pair(indat1,indat2);  %tests if indat1 > indat2  tail 1=one tailed
0003 %
0004 % Copyright (C) 2011, ATR All Rights Reserved.
0005 % License : New BSD License(see VBMEG_LICENSE.txt)
0006 
0007 if nargin<3
0008    tail=0;
0009 end
0010 
0011 n=length(indat1);
0012 d=indat1-indat2;
0013 md=mean(d);
0014 ssd=std(d);
0015 t=(md-0)./(ssd/sqrt(n));
0016 p=1-tcdf(abs(t),n-1);
0017 
0018 %p = one tailed
0019 if tail==0
0020    p=p*2;  %two tailed
0021 else
0022    p=p*tail;
0023 end
0024 df=n-1;
0025

Generated on Tue 27-Aug-2013 11:46:04 by m2html © 2005