Question: Defining Functions to Compute Norms. # Don't change this cell; just run it. import numpy as np import math import matplotlib.pyplot as plt %matplotlib inline
Defining Functions to Compute Norms.
# Don't change this cell; just run it. import numpy as np import math import matplotlib.pyplot as plt %matplotlib inline plt.style.use("fivethirtyeight"), def L1_norm(vector): # Your Code Here ## DO NOT MODIFY BELOW THIS COMMENT ## ## The remainder of this cell will verify the correctness of your L1_norm function num iters, minn, max n, sigma = 1000, 10, 100, 10 for _ in range(num_iters): in = np. random.randint(min_n, max_n) vec = sigma * np. random. randn(n) Ist = vec. tolist(). norm_np = np. linalg.norm(vec, ord=1) norm_test = L1_norm(lst) assert math.isclosed norm_np, norm_test ), "Calculated value ({}) does not match the expected value ({}) for input {}".format( norm_test, norm_np, vec print("Congratulations! Your L1_norm function is correct!")
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
