All problems
Condition Number from SVD
Problem
Compute the 2-norm condition number of a matrix from its singular values:
cond(A) = sigma_max / sigma_min
Return None if the smallest singular value is 0, since the matrix would be singular.
Hint
The condition number measures how much the matrix can stretch versus shrink vectors.
Test cases
case 1
in: [[5,2,1]]
expected: 5
case 2
in: [[3,3]]
expected: 1
case 3
in: [[10,0]]
expected: null
case 4
in: [[2]]
expected: 1
Starter codePython
def condition_from_svd(singular_values):
# Your code here
pass4 test cases · run your code against them in the editor