Skip to content
DeepForgeby svx
All problems
MediumStatisticsst-073

ANOVA Between-Group Sum of Squares

Problem

Return the between-group sum of squares sum(n_j * (mean_j - grand_mean)^2) for a list of groups. Return 0.0 when there are no values.

Hint

Each group mean is weighted by its size.

Test cases

case 1
in: [[[1,2,3],[4,5,6],[7,8,9]]]
expected: 54
case 2
in: [[[5,5],[5,5]]]
expected: 0
case 3
in: [[[1],[2],[3]]]
expected: 2
case 4
in: [[[10,20],[30,40]]]
expected: 400
case 5
in: [[]]
expected: 0
Starter codePython
def anova_between_ss(groups):
    # Your code here
    pass

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