Skip to content
DeepForgeby svx
All problems
MediumStatisticsst-075

F Statistic from Groups

Problem

Return the one-way ANOVA F statistic (SSB/(k-1)) / (SSW/(N-k)) for a list of groups. Return 0.0 when there are fewer than two groups, N <= k, or SSW is zero.

Hint

Divide the mean between-group square by the mean within-group square.

Test cases

case 1
in: [[[1,2,3],[4,5,6],[7,8,9]]]
expected: 27
case 2
in: [[[5,5],[5,5]]]
expected: 0
case 3
in: [[[1,2],[3,4],[5,6]]]
expected: 16
case 4
in: [[[1],[2]]]
expected: 0
case 5
in: [[[10,12,14],[10,12,14]]]
expected: 0
Starter codePython
def f_statistic(groups):
    # Your code here
    pass

5 test cases · run your code against them in the editor