Function File: [h, pval, ci, stats] = ttest2 (x, y)
Function File: [h, pval, ci, stats] = ttest2 (x, y, Name, Value)

Test for mean of a normal sample with known variance.

Perform a T-test of the null hypothesis mean (x) == m for a sample x from a normal distribution with unknown mean and unknown std deviation. Under the null, the test statistic t has a Student’s t distribution.

If the second argument y is a vector, a paired-t test of the hypothesis mean (x) = mean (y) is performed.

The argument "alpha" can be used to specify the significance level of the test (the default value is 0.05). The string argument "tail", can be used to select the desired alternative hypotheses. If "alt" is "both" (default) the null is tested against the two-sided alternative mean (x) != m. If "alt" is "right" the one-sided alternative mean (x) > m is considered. Similarly for "left", the one-sided alternative mean (x) < m is considered. When "vartype" is "equal" the variances are assumed to be equal (this is the default). When "vartype" is "unequal" the variances are not assumed equal. When argument x is a matrix the "dim" argument can be used to selection the dimension over which to perform the test. (The default is the first non-singleton dimension.)

If h is 0 the null hypothesis is accepted, if it is 1 the null hypothesis is rejected. The p-value of the test is returned in pval. A 100(1-alpha)% confidence interval is returned in ci. stats is a structure containing the value of the test statistic (tstat), the degrees of freedom (df) and the sample standard deviation (sd).

Package: statistics