7. You are comparing the average daily sales between two stores. Store A has a mean daily sales value of $1,000 with a standard deviation of $100 over 30 days, and Store B has a mean daily sales value of $950 with a standard deviation of $120 over 30 days. Conduct a two-sample t-test to determine if there is a significant difference between the average sales of the two stores at the 5% significance level.
PROGRAM:
from scipy import stats
import math
# Given data
mean_A = 1000
std_A = 100
n_A = 30
mean_B = 950
std_B = 120
n_B = 30
alpha = 0.05 # significance level
# Calculate the t-statistic for two independent samples (unequal variances)
t_stat = (mean_A - mean_B) / math.sqrt((std_A**2 / n_A) + (std_B**2 / n_B))
# Degrees of freedom using Welch-Satterthwaite equation
df = ((std_A**2 / n_A + std_B**2 / n_B)**2) / (((std_A**2 / n_A)**2 / (n_A - 1)) + ((std_B**2 / n_B)**2 / (n_B - 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"Degrees of freedom: {df:.2f}")
print(f"P-value: {p_value:.5f}")
# Conclusion
if p_value < alpha:
print("Reject the null hypothesis: There is a significant difference between the average sales of the two stores.")
else:
print("Fail to reject the null hypothesis: No significant difference between the average sales of the two stores.")
OUTPUT:
T-statistic: 1.753
Degrees of freedom: 56.17
P-value: 0.08502
Fail to reject the null hypothesis: No significant difference between the average sales of the two stores.