Last Updated : 23 Jul, 2025
One-Way ANOVA is a statistical test used to check if there are significant differences between the means of three or more groups i.e analysis of variance. It helps us to find whether the variations in data are due to different treatments or random chance.
Hypotheses in One-Way ANOVAOne-way ANOVA has null and alternative hypotheses:
Example:
Imagine we want to compare the performance of four different engine oils used in cars. The cars drive 100 kilometers with each type of oil and their performance is recorded. We want to check if the performance differs depending on the oil used. Now we will use One-Way ANOVA test in Python with following steps:
Step 1: Install Required LibrariesWe need to install the SciPy library in our system. We can install it using below command in terminal:
Step 2: Create Data Groupspip3 install scipy
We create arrays representing the performance of cars with each engine oil.
Python
performance1 = [89, 89, 88, 78, 79]
performance2 = [93, 92, 94, 89, 88]
performance3 = [89, 88, 89, 93, 90]
performance4 = [81, 78, 81, 92, 82]
Step 3: Perform One-Way ANOVA
Now we use the f_oneway() function from SciPy to conduct the One-Way ANOVA test.
Python
from scipy.stats import f_oneway
f_statistic, p_value = f_oneway(performance1, performance2, performance3, performance4)
print(f"F-statistic: {f_statistic}")
print(f"P-value: {p_value}")
Output:
Result Step 4: Analyze the ResultThe output will provide two important values:
Since p-value is less than 0.05 hence we would reject the null hypothesis. This implies that we have sufficient proof to say that there exists a difference in performance among four different engine oils.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4