All problems
Lipschitz Estimate
Problem
Estimate a Lipschitz constant for a gradient field from sampled gradients.
Return the largest Euclidean norm among the supplied gradient vectors, or 0.0 when the list is empty. Each gradient is given as a list of components.
Hint
Take the maximum gradient norm over the sampled points.
Test cases
case 1
in: [[[1,2],[0,1]]]
expected: 2.23606797749979
case 2
in: [[[3,4]]]
expected: 5
case 3
in: [[]]
expected: 0
case 4
in: [[[0,0]]]
expected: 0
Starter codePython
def lipschitz_estimate(grads):
# Your code here
pass4 test cases · run your code against them in the editor