#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ ENGG1811. Illustrating the numpy max and argmax functions """ import numpy as np # Problem parameters array1 = np.array([ [-3.2, 0, 6.2, 5.8], [ 6, -4, 0.5, 7.1], [ 3.8, 5, 2.7, 3.7]]) # max print(np.max(array1)) # default parameter value print(np.max(array1, axis = 0)) # along axis 0 print(np.max(array1, axis = 1)) # along axis 1 # argmax - along an axis print(np.argmax(array1, axis = 0)) # along axis 0 print(np.argmax(array1, axis = 1)) # along axis 1 # %% argmax for arrays with higher dimension # index_max = np.argmax(array1) # indices = np.unravel_index(index_max, array1.shape) # indices is of the type tuple # try type(indices) # indices[0] # indices[1]