XLSTAT - Two sample t and z tests

View a tutorial

Parametric t and z tests are used to compare the means of two samples. The calculation method differs according to the nature of the samples. A distinction is made between independent samples or paired samples.
The t and z tests are known as parametric because the assumption is made that the samples are normally distributed.

Comparison of the means of two independent samples

Take a sample S1 comprising n1 observations, of mean µ1 and variance s1². Take a second sample S2, independent of S1 comprising n2 observations, of mean µ2 and variance s2². Let D be the assumed difference between the means (D is 0 when equality is assumed).

As for the z and t tests on a sample, we use:

  1. Student's t test if the true variance of the populations from which the samples are extracted is not known;
  2. The z test if the true variance s² of the population is known.

Student's t Test

The use of Student's t test requires a decision to be taken beforehand on whether variances of the samples are to be considered equal or not. XLSTAT gives the option of using Fisher's F test to test the hypothesis of equality of the variances and to use the result of the test in the subsequent calculations.
If we consider that the two samples have the same variance, the common variance is estimated by:

s² = [(n1-1)s1² + (n2-1)s2²] / (n1 + n2 - 2)

The test statistic is therefore given by:

t = (µ1 - µ2 -D) / (s 1/n1 + 1/n2)

The t statistic follows a Student distribution with n1+n2-2 degrees of freedom.

If we consider that the variances are different, the statistic is given by:

t = (µ1 - µ2 -D) / ( s1²/n1 + s2²/n2)


For the z-test, the variance σ ² of the population is presumed to be known. The user can enter this value or estimate it from the data (this is offered for teaching purposes only). The test statistic is given by:

z = (µ1 - µ2 -D) / ( σ 1/n1 + 1/n2)

The z statistic follows a normal distribution.

Comparison of the means of two paired samples

If two samples are paired, they have to be of the same size. Where values are missing from certain observations, either the observation is removed from both samples or the missing values are estimated.

We study the mean of the calculated differences for the n observations. If d is the mean of the differences, s² the variance of the differences and D the supposed difference, the statistic of the t test is given by:

T= (d-D) (s/ n)

The t statistic follows a Student distribution with n-1 degrees of freedom.

For the z test, the statistic is as follows where σ ² is the variance

z= (d-D) ( σ / n)

The z statistic follows a normal distribution.

Alternative hypotheses

Three types of test are possible depending on the alternative hypothesis chosen:

  • two-tailed test,
  • left-tailed test,
  • right-tailed test.


This analysis is available in the XLStat-Base addin for Microsoft Excel

About KCS

Kovach Computing Services (KCS) was founded in 1993 by Dr. Warren Kovach. The company specializes in the development and marketing of inexpensive and easy-to-use statistical software for scientists, as well as in data analysis consulting.

Mailing list Join our mailing list

Home | Order | MVSP | Oriana | XLStat
QDA Miner | Accent Composer | Stats Books
Stats Links | Anglesey

Share: FacebookFacebook TwitterTwitter RedditReddit
Del.icio.usDel.icio.us Stumble UponStumble Upon


Like us on Facebook

Get in Touch

  • Email:
  • Address:
    85 Nant y Felin
    Pentraeth, Isle of Anglesey
    LL75 8UY
    United Kingdom
  • Phone:
    (UK): 01248-450414
    (Intl.): +44-1248-450414