Cermain's introduction to the t-test is fairly accurate, but I feel lacks some information.

The t-test is a statistical tes twhich allows you to compare two independent samples or to compare a single sample against a theoretical mean. It is a univariate procedure, meaning that you can only compare the values of one variable at a time.

The two statistical hypotheses normally tested are:

• H0: The mean for sample 1 is equal to the mean for sample two, or μ1=μs2
• H1: The mean for sample 1 is not equal to the mean for sample two, or μ1 ≠ μ2. (note that this can be modified to include the unilateral case)
The auxiliary statistic t (the value compared against a theoretical distribution) is calculated as:

tc = (mean(x1)-mean(x2))/spd√(1/n1 +1/n2)

This value of t is compared against the Student's t distribution with ν=n1+n2-2 degrees of freedom. The conditions of the t-test are as follows:

1. The samples be independent
2. The two samples be distributed normally
3. The variances of the two samples are equal
If the two variances are not equal, then a modified version of the test may be applied.

tmc = (mean(x1)-mean(x2))/√(s2x1 /n1 +s2x2/n2)

Where tmc is compared with the theoretical Student's t distribution with a modified number of degrees of freedom. There is also a modification of the t-test under the circumstances where the two samples are paired (an example of this situation is where you take a measurement of a subject before and after a manipulation; the samples are not independent because the same subject is measured twice).

td = mean(d)/smean(d)

where mean(d) and sd are the mean value and standard deviation of the differences between sample 1 and sample 2 for each subject, and smean(d)=sd/√n and sd.