All problems
Sphericity Check Lite
Problem
Return True when all pairwise difference variances S_ii + S_jj - 2*S_ij are equal within 1e-9 for a square covariance matrix, and False otherwise (including non-square or fewer than two variables).
Hint
Sphericity always holds for two repeated measures but can fail with three or more.
Test cases
case 1
in: [[[2,2,2],[2,3,2.5],[2,2.5,3]]]
expected: true
case 2
in: [[[1,0.2,0.5],[0.2,1,0.3],[0.5,0.3,1]]]
expected: false
case 3
in: [[[1,0.5],[0.5,1]]]
expected: true
case 4
in: [[[2,1],[1,2]]]
expected: true
case 5
in: [[]]
expected: false
Starter codePython
def sphericity_check_lite(matrix):
# Your code here
pass5 test cases · run your code against them in the editor