In the previous example, we set up a hypothesis to test whether a sample mean was close to a population mean or desired
value for some soil samples containing arsenic. On this page, we establish the statistical test to determine whether
the difference between the sample mean and the population mean is significant. It is called the *t*-test, and
it is used when comparing sample means, when only the sample standard deviation is known.

The *t*-test, and any statistical test of this sort, consists of three steps.

- Define the null and alternate hyptheses,
- Calculate the
*t*-statistic for the data, - Compare
*t*to the tabulated_{calc}*t*-value, for the appropriate significance level and degree of freedom. If, we reject the null hypothesis and accept the alternate hypothesis. Otherwise, we accept the null hypothesis.*t*>_{calc}*t*_{tab}

The *t*-test can be used to compare a sample mean to an accepted value (a population mean), or it can be
used to compare the means of two sample sets.

*t*-test to Compare One Sample Mean to an Accepted Value

In the example, the mean of arsenic concentration measurements was *m*=4 ppm, for n=7 and, with
sample standard deviation *s*=0.9 ppm. We established suitable null and alternative hypostheses:

**Null Hypothesis***H*_{0}:*μ*=*μ*_{0}**Alternate Hypothesis***H*_{A}:*μ*>*μ*_{0}

where *μ*_{0} = 2 ppm is the allowable limit and *μ* is the population mean of the measured
soil (refresher on the difference between sample and population means).

We have already seen how to do the first step, and have null and alternate hypotheses. The second step involves the
calculation of the *t*-statistic for one mean, using the formula:

where *s* is the standard deviation of the sample, not the population standard deviation. In our case,

For the third step, we need a table of tabulated *t*-values for significance level and degrees of freedom,
such as the one found in your lab manual or most statistics textbooks. Referring to a table for a 95%
confidence limit for a 1-tailed test, we find *t*_{ν=6,95%} = 1.94. (The difference between
1- and 2-tailed distributions was covered in a previous section.)

We are now ready to accept or reject the null hypothesis. If the *t _{calc}* >

*t*, we reject the null hypothesis. In our case,

_{tab}*t*=5.88 >

_{calc}*t*=2.45, so we reject the null hypothesis, and say that our sample mean is indeed larger than the accepted limit, and not due to random chance, so we can say that the soil is indeed contaminated.

_{tab}*t*-test to Compare Two Sample Means

The method for comparing two sample means is very similar. The only two differences are the equation used to compute
the *t*-statistic, and the degrees of freedom for choosing the tabulate *t*-value. The formula is given by

In this case, we require two separate sample means, standard deviations and sample sizes. The number of degrees of freedom is computed using the formula

and the result is rounded to the nearest whole number. Once these quantities are determined, the same
three steps for determining the validity of a hypothesis are used for two sample means.
The next page, which describes the difference between one- and two-tailed tests, also
provides an example of how to perform two sample mean *t*-tests.