Question: Using python for this. Will rate. Thanks 1.The ndarray.argmin () and ndarray.argmax () methods can only return the index from a flat array, which means
1.The ndarray.argmin () and ndarray.argmax () methods can only return the index from a flat array, which means they unfold the n-dim array into 1-d array and return the 1-d index. For example, the following code will return 18. Now we want to obtain a tuple of indices which can be used to locate the minimum or maximum. Each element of the tuple is the index of minimum or maximum in the corresponding dimension. In the following example we want to find (4,2), so that arrayt4,21 will give the maximum. np.random.seed (10) array2 np.random.randn (5, 4) print (array2) array2.argmax () Please write two functions array_argmin(arr) and array_argmax (arr) where the input arr is an n-dim array, and the functions will return a tuple of n indices for the minimum and maximum respectively
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
