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

Test for mean of a normal sample with unknown 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. The default value of m is 0.

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

Name-Value pair arguments can be used to set various options. "alpha" can be used to specify the significance level of the test (the default value is 0.05). "tail", can be used to select the desired alternative hypotheses. If the value is "both" (default) the null is tested against the two-sided alternative mean (x) != m. If it is "right" the one-sided alternative mean (x) > m is considered. Similarly for "left", the one-sided alternative mean (x) < m is considered. When argument x is a matrix, "dim" 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