Documentation of ttest_dan


Global Index (all files) (short | long) | Local Index (files in subdir) (short | long)


Function Synopsis

[tstat, dof] = ttest(x1, x2);

Help text


  [tstat, dof] = ttest(x1, x2);

  This program returns the t-statistic for a difference
  in two means that should come from the same population.  
  The resulting t-statistic should be compared against 
  known charts of t-statistics, using 'dof' as the degrees
  of freedom.


Listing of function ttest_dan

function [tstat, dof] = ttest(x1, x2);

[m1, n1] = size(x1);
[m2, n2] = size(x2);

dof = m1 + m2 - 2;

sig = squeeze(sqrt( ( (m1 * (std(x1)).^2) + m2 * (std(x2)).^2 ) / dof ));
sig = sig * sqrt((1/m1) + (1/m2));

sig(find(sig == 0)) = NaN * ones(size(find(sig == 0)));

tstat = squeeze((mean(x1) - mean(x2))) ./ sig;