Skip to content
DeepForgeby svx
All problems
EasyStatisticsst-216

Compound Symmetry Check

Problem

Return True when a square covariance matrix has one common diagonal value and one common off-diagonal value within 1e-9, and False otherwise (including non-square or empty input).

Hint

Compound symmetry is the covariance structure assumed by repeated-measures ANOVA.

Test cases

case 1
in: [[[1,0.5],[0.5,1]]]
expected: true
case 2
in: [[[1,0.5],[0.5,2]]]
expected: false
case 3
in: [[[2,1,1],[1,2,1],[1,1,2]]]
expected: true
case 4
in: [[[2,1,0],[1,2,1],[0,1,2]]]
expected: false
case 5
in: [[]]
expected: false
Starter codePython
def compound_symmetry_check(matrix):
    # Your code here
    pass

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