# One sample z test for the mean - overview

This page offers structured overviews of one or more selected methods. Add additional methods for comparisons by clicking on the dropdown button in the right-hand column. To practice with a specific method click the button at the bottom row of the table

One sample $z$ test for the mean
Binomial test for a single proportion
Two sample $z$ test
Two sample $t$ test - equal variances assumed
Independent variableIndependent variableIndependent/grouping variableIndependent/grouping variable
NoneNoneOne categorical with 2 independent groupsOne categorical with 2 independent groups
Dependent variableDependent variableDependent variableDependent variable
One quantitative of interval or ratio levelOne categorical with 2 independent groupsOne quantitative of interval or ratio levelOne quantitative of interval or ratio level
Null hypothesisNull hypothesisNull hypothesisNull hypothesis
H0: $\mu = \mu_0$

Here $\mu$ is the population mean, and $\mu_0$ is the population mean according to the null hypothesis.
H0: $\pi = \pi_0$

Here $\pi$ is the population proportion of 'successes', and $\pi_0$ is the population proportion of successes according to the null hypothesis.
H0: $\mu_1 = \mu_2$

Here $\mu_1$ is the population mean for group 1, and $\mu_2$ is the population mean for group 2.
H0: $\mu_1 = \mu_2$

Here $\mu_1$ is the population mean for group 1, and $\mu_2$ is the population mean for group 2.
Alternative hypothesisAlternative hypothesisAlternative hypothesisAlternative hypothesis
H1 two sided: $\mu \neq \mu_0$
H1 right sided: $\mu > \mu_0$
H1 left sided: $\mu < \mu_0$
H1 two sided: $\pi \neq \pi_0$
H1 right sided: $\pi > \pi_0$
H1 left sided: $\pi < \pi_0$
H1 two sided: $\mu_1 \neq \mu_2$
H1 right sided: $\mu_1 > \mu_2$
H1 left sided: $\mu_1 < \mu_2$
H1 two sided: $\mu_1 \neq \mu_2$
H1 right sided: $\mu_1 > \mu_2$
H1 left sided: $\mu_1 < \mu_2$
AssumptionsAssumptionsAssumptionsAssumptions
• Scores are normally distributed in the population
• Population standard deviation $\sigma$ is known
• Sample is a simple random sample from the population. That is, observations are independent of one another
• Sample is a simple random sample from the population. That is, observations are independent of one another
• Within each population, the scores on the dependent variable are normally distributed
• Population standard deviations $\sigma_1$ and $\sigma_2$ are known
• Group 1 sample is a simple random sample (SRS) from population 1, group 2 sample is an independent SRS from population 2. That is, within and between groups, observations are independent of one another
• Within each population, the scores on the dependent variable are normally distributed
• The standard deviation of the scores on the dependent variable is the same in both populations: $\sigma_1 = \sigma_2$
• Group 1 sample is a simple random sample (SRS) from population 1, group 2 sample is an independent SRS from population 2. That is, within and between groups, observations are independent of one another
Test statisticTest statisticTest statisticTest statistic
$z = \dfrac{\bar{y} - \mu_0}{\sigma / \sqrt{N}}$
Here $\bar{y}$ is the sample mean, $\mu_0$ is the population mean according to the null hypothesis, $\sigma$ is the population standard deviation, and $N$ is the sample size.

The denominator $\sigma / \sqrt{N}$ is the standard deviation of the sampling distribution of $\bar{y}$. The $z$ value indicates how many of these standard deviations $\bar{y}$ is removed from $\mu_0$.
$X$ = number of successes in the sample$z = \dfrac{(\bar{y}_1 - \bar{y}_2) - 0}{\sqrt{\dfrac{\sigma^2_1}{n_1} + \dfrac{\sigma^2_2}{n_2}}} = \dfrac{\bar{y}_1 - \bar{y}_2}{\sqrt{\dfrac{\sigma^2_1}{n_1} + \dfrac{\sigma^2_2}{n_2}}}$
Here $\bar{y}_1$ is the sample mean in group 1, $\bar{y}_2$ is the sample mean in group 2, $\sigma^2_1$ is the population variance in population 1, $\sigma^2_2$ is the population variance in population 2, $n_1$ is the sample size of group 1, and $n_2$ is the sample size of group 2. The 0 represents the difference in population means according to the null hypothesis.

The denominator $\sqrt{\frac{\sigma^2_1}{n_1} + \frac{\sigma^2_2}{n_2}}$ is the standard deviation of the sampling distribution of $\bar{y}_1 - \bar{y}_2$. The $z$ value indicates how many of these standard deviations $\bar{y}_1 - \bar{y}_2$ is removed from 0.

Note: we could just as well compute $\bar{y}_2 - \bar{y}_1$ in the numerator, but then the left sided alternative becomes $\mu_2 < \mu_1$, and the right sided alternative becomes $\mu_2 > \mu_1$.
$t = \dfrac{(\bar{y}_1 - \bar{y}_2) - 0}{s_p\sqrt{\dfrac{1}{n_1} + \dfrac{1}{n_2}}} = \dfrac{\bar{y}_1 - \bar{y}_2}{s_p\sqrt{\dfrac{1}{n_1} + \dfrac{1}{n_2}}}$
Here $\bar{y}_1$ is the sample mean in group 1, $\bar{y}_2$ is the sample mean in group 2, $s_p$ is the pooled standard deviation, $n_1$ is the sample size of group 1, and $n_2$ is the sample size of group 2. The 0 represents the difference in population means according to the null hypothesis.

The denominator $s_p\sqrt{\dfrac{1}{n_1} + \dfrac{1}{n_2}}$ is the standard error of the sampling distribution of $\bar{y}_1 - \bar{y}_2$. The $t$ value indicates how many standard errors $\bar{y}_1 - \bar{y}_2$ is removed from 0.

Note: we could just as well compute $\bar{y}_2 - \bar{y}_1$ in the numerator, but then the left sided alternative becomes $\mu_2 < \mu_1$, and the right sided alternative becomes $\mu_2 > \mu_1$.
n.a.n.a.n.a.Pooled standard deviation
---$s_p = \sqrt{\dfrac{(n_1 - 1) \times s^2_1 + (n_2 - 1) \times s^2_2}{n_1 + n_2 - 2}}$
Sampling distribution of $z$ if H0 were trueSampling distribution of $X$ if H0 were trueSampling distribution of $z$ if H0 were trueSampling distribution of $t$ if H0 were true
Standard normal distributionBinomial($n$, $P$) distribution.

Here $n = N$ (total sample size), and $P = \pi_0$ (population proportion according to the null hypothesis).
Standard normal distribution$t$ distribution with $n_1 + n_2 - 2$ degrees of freedom
Significant?Significant?Significant?Significant?
Two sided:
Right sided:
Left sided:
Two sided:
• Check if $X$ observed in sample is in the rejection region or
• Find two sided $p$ value corresponding to observed $X$ and check if it is equal to or smaller than $\alpha$
Right sided:
• Check if $X$ observed in sample is in the rejection region or
• Find right sided $p$ value corresponding to observed $X$ and check if it is equal to or smaller than $\alpha$
Left sided:
• Check if $X$ observed in sample is in the rejection region or
• Find left sided $p$ value corresponding to observed $X$ and check if it is equal to or smaller than $\alpha$
Two sided:
Right sided:
Left sided:
Two sided:
Right sided:
Left sided:
$C\%$ confidence interval for $\mu$n.a.$C\%$ confidence interval for $\mu_1 - \mu_2$$C\% confidence interval for \mu_1 - \mu_2 \bar{y} \pm z^* \times \dfrac{\sigma}{\sqrt{N}} where the critical value z^* is the value under the normal curve with the area C / 100 between -z^* and z^* (e.g. z^* = 1.96 for a 95% confidence interval). The confidence interval for \mu can also be used as significance test. -(\bar{y}_1 - \bar{y}_2) \pm z^* \times \sqrt{\dfrac{\sigma^2_1}{n_1} + \dfrac{\sigma^2_2}{n_2}} where the critical value z^* is the value under the normal curve with the area C / 100 between -z^* and z^* (e.g. z^* = 1.96 for a 95% confidence interval). The confidence interval for \mu_1 - \mu_2 can also be used as significance test. (\bar{y}_1 - \bar{y}_2) \pm t^* \times s_p\sqrt{\dfrac{1}{n_1} + \dfrac{1}{n_2}} where the critical value t^* is the value under the t_{n_1 + n_2 - 2} distribution with the area C / 100 between -t^* and t^* (e.g. t^* = 2.086 for a 95% confidence interval when df = 20). The confidence interval for \mu_1 - \mu_2 can also be used as significance test. Effect sizen.a.n.a.Effect size Cohen's d: Standardized difference between the sample mean and \mu_0:$$d = \frac{\bar{y} - \mu_0}{\sigma}$$Cohen's d indicates how many standard deviations \sigma the sample mean \bar{y} is removed from \mu_0. --Cohen's d: Standardized difference between the mean in group 1 and in group 2:$$d = \frac{\bar{y}_1 - \bar{y}_2}{s_p}$$Cohen's$d$indicates how many standard deviations$s_p$the two sample means are removed from each other. Visual representationn.a.Visual representationVisual representation - n.a.n.a.n.a.Equivalent to ---One way ANOVA with an independent variable with 2 levels ($I$= 2): • two sided two sample$t$test is equivalent to ANOVA$F$test when$I$= 2 • two sample$t$test is equivalent to$t$test for contrast when$I$= 2 • two sample$t$test is equivalent to$t$test multiple comparisons when$I$= 2 OLS regression with one categorical independent variable with 2 levels: • two sided two sample$t$test is equivalent to$F$test regression model • two sample$t$test is equivalent to$t$test for regression coefficient$\beta_1$Example contextExample contextExample contextExample context Is the average mental health score of office workers different from$\mu_0 = 50$? Assume that the standard deviation of the mental health scores in the population is$\sigma = 3.$Is the proportion of smokers amongst office workers different from$\pi_0 = 0.2$?Is the average mental health score different between men and women? Assume that in the population, the standard devation of the mental health scores is$\sigma_1 = 2$amongst men and$\sigma_2 = 2.5$amongst women.Is the average mental health score different between men and women? Assume that in the population, the standard deviation of mental health scores is equal amongst men and women. n.a.SPSSn.a.SPSS -Analyze > Nonparametric Tests > Legacy Dialogs > Binomial... • Put your dichotomous variable in the box below Test Variable List • Fill in the value for$\pi_0$in the box next to Test Proportion -Analyze > Compare Means > Independent-Samples T Test... • Put your dependent (quantitative) variable in the box below Test Variable(s) and your independent (grouping) variable in the box below Grouping Variable • Click on the Define Groups... button. If you can't click on it, first click on the grouping variable so its background turns yellow • Fill in the value you have used to indicate your first group in the box next to Group 1, and the value you have used to indicate your second group in the box next to Group 2 • Continue and click OK n.a.Jamovin.a.Jamovi -Frequencies > 2 Outcomes - Binomial test • Put your dichotomous variable in the white box at the right • Fill in the value for$\pi_0\$ in the box next to Test value
• Under Hypothesis, select your alternative hypothesis
-T-Tests > Independent Samples T-Test
• Put your dependent (quantitative) variable in the box below Dependent Variables and your independent (grouping) variable in the box below Grouping Variable
• Under Tests, select Student's (selected by default)
• Under Hypothesis, select your alternative hypothesis
Practice questionsPractice questionsPractice questionsPractice questions
{"ft_lang_label":"__label__en","ft_lang_prob":0.7638064,"math_prob":0.9993698,"size":8044,"snap":"2023-40-2023-50","text_gpt3_token_len":2587,"char_repetition_ratio":0.14577115,"word_repetition_ratio":0.38199514,"special_character_ratio":0.33416212,"punctuation_ratio":0.09431345,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99987936,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-12-04T13:15:10Z\",\"WARC-Record-ID\":\"<urn:uuid:61d20eb0-4d31-4054-9b0a-f053d3897ee6>\",\"Content-Length\":\"35398\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:7e5713cf-246b-4c62-b4a8-2fb2a6576abd>\",\"WARC-Concurrent-To\":\"<urn:uuid:0be2047a-e986-4677-b882-2d150fb674e0>\",\"WARC-IP-Address\":\"141.138.168.125\",\"WARC-Target-URI\":\"https://statkat.com/stattest.php?t=5&t2=44&t3=8&t4=10\",\"WARC-Payload-Digest\":\"sha1:VRYJ4FFIMQAQGU2AXCC5NKLP2O533NZG\",\"WARC-Block-Digest\":\"sha1:M32I4M4XX33S4K4IQ2FMTVWQU3YMSB5Q\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-50/CC-MAIN-2023-50_segments_1700679100529.8_warc_CC-MAIN-20231204115419-20231204145419-00330.warc.gz\"}"}