Loading, please wait...

BAD702 Program 5

5. A researcher conducts an experiment with a sample of 20 participants to determine if a new drug affects heart rate. The sample has a mean heart rate increase of 8 beats per minute and a standard deviation of 2 beats per minute. Perform a hypothesis test using the t-distribution to determine if the mean heart rate increase is significantly different from zero at the 5% significance level.

PROGRAM:

from scipy import stats
import math

# Given data
sample_mean = 8      # mean heart rate increase
sample_std = 2       # standard deviation
n = 20               # sample size
alpha = 0.05         # significance level

# Calculate t-statistic
t_stat = sample_mean / (sample_std / math.sqrt(n))

# Degrees of freedom
df = n - 1

# Two-tailed p-value
p_value = 2 * (1 - stats.t.cdf(abs(t_stat), df=df))

# Print results
print(f"T-statistic: {t_stat:.3f}")
print(f"P-value: {p_value:.5f}")

# Conclusion
if p_value < alpha:
    print("Reject the null hypothesis: The mean heart rate increase is significantly different from zero.")
else:
    print("Fail to reject the null hypothesis: No significant difference from zero.")

OUTPUT:

T-statistic: 17.889
P-value: 0.00000
Reject the null hypothesis: The mean heart rate increase is significantly different from zero.
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x