All problems
PSD Kernel Check 2x2
Problem
Return True if the 2x2 matrix K is a valid positive semidefinite kernel matrix: symmetric within 1e-9, trace >= 0, and determinant >= -1e-9.
Otherwise return False.
Hint
For a 2x2 symmetric matrix, PSD is equivalent to non-negative trace and determinant.
Test cases
case 1
in: [[[1,0.5],[0.5,1]]]
expected: true
case 2
in: [[[1,2],[2,1]]]
expected: false
case 3
in: [[[0,0],[0,0]]]
expected: true
case 4
in: [[[1,2],[3,1]]]
expected: false
Starter codePython
def is_psd_kernel_2x2(K):
# Your code here
pass4 test cases · run your code against them in the editor