18.2.4.6. ANOVA - Analysis of variance#

18.2.4.6.1. Metodo#

18.2.4.6.2. Esempio#

# ANOVA - Analysis of variance

import numpy as np
from scipy.stats import f_oneway

# Sample data: test scores from three teaching methods
method_A = [88, 92, 85, 91, 87]
method_B = [78, 85, 80, 83, 79]
method_C = [94, 89, 91, 96, 90]

# Perform one-way ANOVA
f_statistic, p_value = f_oneway(method_A, method_B, method_C)

# Display results
print(f"F-Statistic: {f_statistic}")
print(f"P-Value: {p_value}")

# Interpretation
alpha = 0.05
if p_value < alpha:
    print("Reject the null hypothesis: There is a significant difference between the groups.")
else:
    print("Fail to reject the null hypothesis: No significant difference between the groups.")
F-Statistic: 18.806324110671927
P-Value: 0.00020023178541394456
Reject the null hypothesis: There is a significant difference between the groups.