Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Implement a function that returns an mn matrix whose entries are uniformly randomly distributed in the interval, [0,] for a given value of . Hint:
Implement a function that returns an mn matrix whose entries are uniformly randomly distributed in the interval, [0,] for a given value of .
Hint: Check out Numpy's module for generating (pseudo)random numbers: numpy.random
Use random_mat() function to write another function, perturb_system(X, y, eps), that creates two "perturbations" to the system defined by X and y.
- Let X be the first perturbation. It should have the same dimensions as X, and its entries should lie in the interval [,]. The value of is given by eps.
- The second is y, a small perturbation to the response variable, y. Its entries should also lie in the same interval, [,]
The function should return a perturbed system, X+X and y+y, as a pair.
def random mat (m, n, eps): ### YOUR CODE HERE print(random mat (3, 2, 1e-3)) # Test cell: randepstest - - Z - random mat (5, 3, le-2) assert Z.shape(5, 3) assert ((Z >- 0) & (Z ]".format (EPSILON, EPSI - assert Delta y.shapey.shape, elta y has shape instead of .".format (Delta y.shape, y.shape) assert (np.abs (Delta_y) ]".format (EPSILON, EPSI print ("n(Passed.)") 007 2Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started