Two Sample Z Test

## Description

Here, we will test two sample means for difference with a two sample z test. The mean, standard deviation and sample size for our samples are

(1)
\begin{align} \bar{x}_1 = 193 \ &\ \ \bar{x}_2 = 208 \\ \sigma_1 = 23 \ &\ \ \sigma_2 = 31 \\ n_1 = 88 \ &\ \ n_2 = 97 \end{align}

With the hypotheses

(2)
\begin{align} H_0: \mu_1 = \mu_2 \\ H_1: \mu_1 \neq \mu_2 \end{align}

R does not have a built in 2 sample z test function, so we will manually use the formula

(3)
\begin{align} \frac{(\bar{x}_1 - \bar{x}_2) - 0}{\sqrt{\frac{\sigma^{2}_{1}}{n_1} + \frac{\sigma^{2}_{2}}{n_2}}} \end{align}

## Sage Cell

Because our p-value is below $\alpha = 0.05$, we reject the null hypothesis. We have sufficient evidence to suggest $\mu_1 \neq \mu_2$.

#### Code

x2 <- 208
sd1 <- 23
sd2 <- 31
n1 <- 88
n2 <- 97
Z <- (x1 - x2)/(sqrt(sd1^2/n1 + sd2^2/n2))
2 * pnorm(Z)


none

## Tags

Primary Tags:

Secondary Tags:

A list of possible tags can be found at The WeBWorK Open Problem Library. For linear algebra tags see the Curated Courses Project.

## Related Cells

Any related cells go here. Provide a link to the page containing the information about the cell.