Skip to content
DeepForgeby svx
All problems
EasyStatisticsst-225

Eigenvalue Diagnostics

Problem

Return [count, elbow] where count is the number of eigenvalues greater than 1 and elbow is the 1-based index farthest from the line joining the first and last eigenvalue points (or 1 when there are fewer than three). Return [0, 0] for empty input.

Hint

The elbow is the point of maximum deviation from the line through the endpoints.

Test cases

case 1
in: [[3,1.5,1,0.5]]
expected: [2,2]
case 2
in: [[5,3,1,0.5,0.2]]
expected: [2,3]
case 3
in: [[1,1,1]]
expected: [0,1]
case 4
in: [[2,1,0.5]]
expected: [1,2]
case 5
in: [[]]
expected: [0,0]
Starter codePython
def eigen_diagnostics(eigenvalues):
    # Your code here
    pass

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