import numpy as np
import pandas as pd
import scipy.stats as stats

# Set random seed so the results are exactly the same every time you run it
np.random.seed(42)

# ==========================================
# 1. GENERATE DATA (No external files needed)
# ==========================================
control_scores = np.random.normal(loc=70, scale=10, size=50)
treatment_scores = np.random.normal(loc=76, scale=12, size=50)

df_groups = pd.DataFrame({
    'Control': control_scores,
    'Treatment': treatment_scores
})

# ==========================================
# 2. DESCRIPTIVE STATISTICS
# ==========================================
print("--- DESCRIPTIVE STATISTICS ---")
print(df_groups.describe().round(2))
print("\n")

# ==========================================
# 3. INFERENTIAL STATISTICS (Independent T-Test)
# ==========================================
print("--- INFERENTIAL STATISTICS (T-Test) ---")
t_stat, p_value = stats.ttest_ind(df_groups['Control'], df_groups['Treatment'])

# Replaced f-strings with .format() for Python 2.7 compatibility
print("T-statistic: {:.4f}".format(t_stat))
print("P-value:     {:.4f}".format(p_value))

if p_value < 0.05:
    print("Conclusion: Reject the null hypothesis (Statistically significant).")
else:
    print("Conclusion: Fail to reject the null hypothesis (No significant difference).")
print("\n")

# ==========================================
# 4. CORRELATION ANALYSIS
# ==========================================
print("--- CORRELATION ANALYSIS ---")
hours_studied = np.random.uniform(low=1, high=10, size=100)
final_scores = 50 + (3.5 * hours_studied) + np.random.normal(loc=0, scale=5, size=100) 

corr_coeff, p_val_corr = stats.pearsonr(hours_studied, final_scores)

# Replaced f-strings with .format() for Python 2.7 compatibility
print("Pearson Correlation Coefficient (r): {:.4f}".format(corr_coeff))
print("P-value: {:.4e}".format(p_val_corr))

if corr_coeff > 0.7:
    print("Conclusion: Strong positive correlation.")
elif corr_coeff > 0.3:
    print("Conclusion: Moderate positive correlation.")
else:
    print("Conclusion: Weak or no correlation.")# your code goes here