All problems
Intraclass Correlation
Problem
Return the ANOVA intraclass correlation (MSB - MSW) / (MSB + (m-1)*MSW) for equal-sized groups of size m. Return 0.0 when there are fewer than two groups, groups are empty or unequal in size, or the denominator is zero.
Hint
It compares between-group and within-group mean squares.
Test cases
case 1
in: [[[1,2,3],[4,5,6],[7,8,9]]]
expected: 0.896551724137931
case 2
in: [[[1,1,1],[5,5,5]]]
expected: 1
case 3
in: [[[1,3,5],[2,3,4]]]
expected: -0.5
case 4
in: [[[1,2],[2,3]]]
expected: 0.3333333333333333
case 5
in: [[[1],[2,3]]]
expected: 0
Starter codePython
def intraclass_correlation(groups):
# Your code here
pass5 test cases · run your code against them in the editor