All problems
Condition Number
Problem
Compute the condition number of a design matrix X with two columns: sqrt(lambda_max / lambda_min) where the lambdas are the eigenvalues of X^T X.
Return 0.0 when the smaller eigenvalue is non-positive.
Hint
Large condition numbers mean the normal equations are poorly conditioned.
Test cases
case 1
in: [[[1,0],[0,1]]]
expected: 1
case 2
in: [[[1,0],[0,2]]]
expected: 2
case 3
in: [[[1,1],[1,1]]]
expected: 0
case 4
in: [[[1,1],[1,2]]]
expected: 6.854101966249688
Starter codePython
def condition_number(X):
# Your code here
pass4 test cases · run your code against them in the editor