Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

image text in transcribed

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.

  1. 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.
  2. 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.

image text in transcribedimage text in transcribed

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 2

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions