A one-sample z-test assesses the sample mean of a variable against a population mean, whilst a two-sample z-test compares the mean from two different groups. The differences are compared with the estimated standard error to conclude whether there is evidence that the population means differ.


It is generally accepted that a sample size of at least 30 is required for a z-test to be applicable because by the Central Limit Theorem we know the sample mean will be normally distributed, even if the population is not. A test statistic is calculated and compared against the critical values at the relevant significant level, to conclude whether the evidence supports or rejects the null hypothesis. Z-tests have a single critical value for each probability value regardless of the sample size, for example 1.96 for a p-value of 0.05.




Z-scores measure how many standard deviations an observation is away from the mean. They can either be included as part of a z-test, or used separately and they allow us to compare datasets measured in different units. A z-score of 0 indicates a data point identical to the mean. Outliers would usually be described as z-scores above 2 or below -2 because roughly 95% of values will be within two standard deviations.


The STANDARDIZE function in Excel measures z-scores.



One-sample z-test worked example

We are going to perform a one-sample z-test, firstly breaking down the calculations and then using the Excel function to fast track getting a p-value. We are investigating how the amount of goals scored per game in this season’s Premier League football season compares to the overall average for Premier League seasons. Our measurement is the number of goals scored per game, in the Premier League era the average is 2.653 but this season the average has been 2.722. Our hypothesis tests whether this is significant or down to random fluctuations, working to a 5% significance level.



For a one-sample z-test at 5% significance our critical value is 1.96. If the z-score is less than -1.96 or more than 1.96 we can reject the null hypothesis.


We need our sample mean (x-bar) which is 2.722 goals per game this season and ‘s’ our sample standard deviation (which is 1.514). Our number of observations, ‘n’, is 288 which is the number of matches played so far this season. ‘A’ is our hypothesised mean, 2.653, which is the average goals per game over the course of 10,506 matches played in the Premier League era before this season. With these inputs we can calculate our test statistic:



The test statistic of 0.773 (to three decimal places) is between the critical values of -1.96 and 1.96 so we cannot reject the null hypothesis. In this instance there is no evidence to support the number of goals scored this season differs significantly to an average Premier League season.


Although it’s useful to know the methodology, the Z.TEST function in Excel is a quicker way to get your result. You don’t need to find the z-score or critical value to use the function, as it goes straight to the p-value.


The function to use is Z.TEST(sample_range, mean[,stdev]. You should supply the population standard deviation if known, alternatively and in this example the sample standard deviation is used as we enter the formula =Z.TEST(A1:A288, 2.653, 1.514) to give us the p-value for the 288 observations against our hypothesised mean.


The p-value is 0.219. This tells us there is around a 22% probability of a random sample (in this case this season’s goals per games) being at least as far from the population mean as this sample. This is considerably above the 5% significance threshold set by our hypothesis.



Two-sample z-test worked example

Our two-sample z-test is going to test the hypothesis that home advantage is a factor in the current Premier League season. Again we will use goals data, comparing the means of home goals and away goals for the 288 matches.


H will represent home and A will represent away. We have 288 matches so n = 288 for both samples and we will also need the sample means (H is 1.507, A is 1.215) and sample standard deviations (H is 1.192, A is 1.208). The first calculation is the Estimated Standard Error (ESE):

Next we calculate z:

The critical values for the 5% significance level are -1.96 and 1.96 so our test statistic of 2.917 means we have evidence to reject the null hypothesis. In fact we can work to a 1% significance level and the test statistic still falls outside of the critical region (between -2.58 and 2.58) so we can reject the null hypothesis to a 1% significance level. There is substantial evidence that goals scored by home teams exceed goals scored by away teams.


There is also an in-built Data Analysis tool in Excel for the two-sample z-test. Ensure you have enabled the Analysis ToolPak in Excel and from the Data tab select Data Analysis in the ribbon and select z-Test: Two Sample for Means.


Beforehand, our data has been setup this way. Note the formulas used for the means and variances of each variable:


In the settings, select the cell ranges for the two variables (in this instance I have ticked to specify that Labels are included in my ranges). The hypothesised mean difference is 0, which describes the null hypothesis that the two variables do not differ. The variance for each variable needs to be manually entered, taken by using the VAR function as shown above. An Alpha of 0.05 specifies the 5% significance level and finally I’ve set the output to be added to a new worksheet:


Our results are returned to the new worksheet. The z-score matches the 2.917 we manually calculated and the z Critical for two-tail matches the 1.96 critical value for the 5% significance level. The key output is the p-value for two-tail of 0.0035 (effectively 0.35%) which demonstrates how we could also reject the null hypothesis at 1% significance, or even 0.5%. Note that p-values and critical values for a one-tailed equivalent z-test are also given: