Exp 7
Exp 7
Roll :12212079
import random
import csv
# Parameters
pop_std_dev = 5 # Population standard deviation
n1, n2 = 6, 6 # Sample sizes
# Calculate means
mean_1 = sum(sample_1) / n1
mean_2 = sum(sample_2) / n2
# Calculate variances
var_1 = sample_variance(sample_1, mean_1)
var_2 = sample_variance(sample_2, mean_2)
# Compute t-score
t_statistic = (mean_1 - mean_2) / pooled_se
df = n1 + n2 - 2 # Degrees of freedom
# Output results
print(f"Sample 1 Data: {sample_1}")
print(f"Sample 2 Data: {sample_2}")
print(f"Mean of Sample 1: {mean_1}")
print(f"Mean of Sample 2: {mean_2}")
print(f"Variance of Sample 1: {var_1}")
print(f"Variance of Sample 2: {var_2}")
print(f"Pooled Standard Error: {pooled_se}")
print(f"T-Statistic: {t_statistic}")
print(f"Degrees of Freedom: {df}")
print(f"T-Critical (α = 0.05): {t_critical_value}")
# Hypothesis testing
if abs(t_statistic) > t_critical_value:
print("Result: Significant difference between the two
samples (Reject H₀).")
else:
print("Result: No significant difference between the
two samples (Fail to reject H₀).")