0
0
SciPydata~20 mins

ANOVA (f_oneway) in SciPy - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
ANOVA Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of One-Way ANOVA Test

What is the output of the following code that performs a one-way ANOVA test on three groups of data?

SciPy
from scipy.stats import f_oneway

group1 = [5, 7, 8, 6, 9]
group2 = [10, 12, 11, 13, 12]
group3 = [7, 8, 7, 6, 7]

stat, p = f_oneway(group1, group2, group3)
print(round(stat, 3), round(p, 3))
A12.5 0.002
B10.8 0.001
C15.0 0.000
D8.3 0.005
Attempts:
2 left
💡 Hint

Recall that the F-statistic measures variance between groups relative to variance within groups.

data_output
intermediate
1:30remaining
Number of Groups in ANOVA Test

How many groups are being compared in this ANOVA test?

SciPy
from scipy.stats import f_oneway

# Data groups
A = [4, 5, 6]
B = [7, 8, 9]
C = [10, 11, 12]
D = [13, 14, 15]

stat, p = f_oneway(A, B, C, D)
print(len([A, B, C, D]))
A4
B3
C2
D5
Attempts:
2 left
💡 Hint

Count the number of lists passed to the function.

🔧 Debug
advanced
2:00remaining
Identify the Error in ANOVA Code

What error does the following code produce?

SciPy
from scipy.stats import f_oneway

group1 = [5, 6, 7]
group2 = 10, 11, 12

stat, p = f_oneway(group1, group2)
print(stat, p)
ATypeError: f_oneway() argument 2 must be a sequence
BValueError: operands could not be broadcast together
CNo error, outputs F-statistic and p-value
DTypeError: unsupported operand type(s) for +: 'int' and 'list'
Attempts:
2 left
💡 Hint

Check the data types of the groups passed to f_oneway.

🚀 Application
advanced
1:30remaining
Interpreting ANOVA Results

You run an ANOVA test and get F-statistic = 2.5 and p-value = 0.12. What does this mean about the groups?

AThere is strong evidence that at least one group mean is different.
BAll group means are exactly equal.
CThe test is invalid because p-value is greater than 0.05.
DThere is no strong evidence to say the group means differ.
Attempts:
2 left
💡 Hint

Remember the p-value threshold for significance is usually 0.05.

🧠 Conceptual
expert
2:00remaining
Assumptions of One-Way ANOVA

Which of the following is NOT an assumption required for a valid one-way ANOVA test?

AThe dependent variable is categorical.
BThe groups have equal variances (homogeneity of variance).
CThe samples are independent of each other.
DThe data in each group are approximately normally distributed.
Attempts:
2 left
💡 Hint

Think about the type of data ANOVA analyzes.