Question 1163253
```python?code_reference&code_event_index=2
import scipy.stats as stats
import numpy as np

def calculate_p_value(x_bar, s, n, mu_0=73):
    t_stat = (x_bar - mu_0) / (s / np.sqrt(n))
    df = n - 1
    # Two-tailed test
    p_value = 2 * (1 - stats.t.cdf(abs(t_stat), df))
    return t_stat, p_value

# Case a
ta, pa = calculate_p_value(70, 6.9, 35)
# Case b
tb, pb = calculate_p_value(76, 6.9, 35)
# Case c
tc, pc = calculate_p_value(70, 6.4, 19)
# Case d
td, pd = calculate_p_value(70, 6.4, 24)

print(f"a: t = {ta:.4f}, p-value = {pa:.4f}")
print(f"b: t = {tb:.4f}, p-value = {pb:.4f}")
print(f"c: t = {tc:.4f}, p-value = {pc:.4f}")
print(f"d: t = {td:.4f}, p-value = {pd:.4f}")


```
```text?code_stdout&code_event_index=2
a: t = -2.5722, p-value = 0.0146
b: t = 2.5722, p-value = 0.0146
c: t = -2.0432, p-value = 0.0560
d: t = -2.2964, p-value = 0.0311

```
To find the p-values for these two-tailed hypothesis tests, we use the $t$-test because the population standard deviation is unknown and the sample standard deviation ($s$) is provided.

The test statistic is calculated as:
$$t = \frac{\bar{x} - \mu_0}{s/\sqrt{n}}$$
The degrees of freedom are $df = n - 1$. Since it is a two-tailed test ($H_A: \mu \neq 73$), the p-value is $2 \times P(T > |t|)$.

### a. $\bar{x} = 70, s = 6.9, n = 35$
* **Test Statistic ($t$):** $\frac{70 - 73}{6.9/\sqrt{35}} \approx -2.572$
* **Degrees of Freedom:** $35 - 1 = 34$
* **p-value:** $P(T < -2.572) + P(T > 2.572) \approx \mathbf{0.0146}$

### b. $\bar{x} = 76, s = 6.9, n = 35$
* **Test Statistic ($t$):** $\frac{76 - 73}{6.9/\sqrt{35}} \approx 2.572$
* **Degrees of Freedom:** $35 - 1 = 34$
* **p-value:** $P(T < -2.572) + P(T > 2.572) \approx \mathbf{0.0146}$
*(Note: Because the distance from the mean is the same as in part 'a', the p-value is identical.)*

### c. $\bar{x} = 70, s = 6.4, n = 19$
* **Test Statistic ($t$):** $\frac{70 - 73}{6.4/\sqrt{19}} \approx -2.043$
* **Degrees of Freedom:** $19 - 1 = 18$
* **p-value:** $2 \times P(T > 2.043) \approx \mathbf{0.0560}$

### d. $\bar{x} = 70, s = 6.4, n = 24$
* **Test Statistic ($t$):** $\frac{70 - 73}{6.4/\sqrt{24}} \approx -2.296$
* **Degrees of Freedom:** $24 - 1 = 23$
* **p-value:** $2 \times P(T > 2.296) \approx \mathbf{0.0311}$