(paired) t-test
H = nan_ttest(x,m) tests Null-hypothesis that mean of x is m. H = nan_ttest(x,y) size of x and size of y must match, it is tested whether the difference x-y is significantly different to m=0; H = nan_ttest(x,y,alpha) H = nan_ttest(x,y,alpha,tail) H = nan_ttest(x,y,alpha,tail,DIM) [H,PVAL] = nan_ttest(...)
For a sample X from a normal distribution with unknown mean and variance, perform a t-test of the null hypothesis `mean (X) == M'. Under the null, the test statistic T follows a Student distribution with `DF = length (X) - 1' degrees of freedom.
TTEST treads NaNs as "Missing values" and ignores these.
H=%T indicates a rejection of the Null-hypothesis at a significance level of alpha (default alpha = 0.05).
With the optional argument string TAIL, the alternative of interest can be selected. If TAIL is '!=' or '<>' or 'both', the null is tested against the two-sided Alternative `mean (X) ~= mean (Y)'. If TAIL is '>' or 'right', the one-sided Alternative `mean (X) > mean (Y)' is used. Similarly for '<' or 'left', the one-sided Alternative `mean (X) < mean (Y)' is used. The default is the two-sided case.
H returns whether the Null-Hypotheses must be rejected. The p-value of the test is returned in PVAL.
TTEST works on the first non-singleton dimension or on DIM.
If no output argument is given, the p-value of the test is displayed. Example before=[223, 259, 248, 220, 287, 191, 229, 270, 245, 201]; after =[220, 244, 243, 211, 299, 170, 210, 276, 252, 189]; [H,pval]=nan_ttest(before,after); // Null-hypothesis will not be rejected // the treatment does not have any effect or the number is to small [H,pval]=nan_ttest(before,after,0.05,'<'); // Null-hypothesis will not be rejected // the treatment does not reduce the value.