Floor, Ceil and Rint python
floor The tool floor returns the floor of the input element-wise. The floor of x is the largest integer i where i<=x. import numpy my_array = numpy.array([1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9.9]) print numpy.floor(my_array) #[ 1. 2. 3. 4. 5. 6. 7. 8. 9.] ceil The tool ceil returns the ceiling of the input element-wise. The ceiling of x is the smallest integer i where i<=x. import numpy my_array = numpy.array([1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9.9]
View Solution →Sum and Prod python
sum The sum tool returns the sum of array elements over a given axis. import numpy my_array = numpy.array([ [1, 2], [3, 4] ]) print numpy.sum(my_array, axis = 0) #Output : [4 6] print numpy.sum(my_array, axis = 1) #Output : [3 7] print numpy.sum(my_array, axis = None) #Output : 10 print numpy.sum(my_array) #Output : 10 By default, the axis value is None. Therefore, it performs a sum over all the dimensions of the input array. prod Th
View Solution →Min and Max python
min The tool min returns the minimum value along a given axis. import numpy my_array = numpy.array([[2, 5], [3, 7], [1, 3], [4, 0]]) print numpy.min(my_array, axis = 0) #Output : [1 0] print numpy.min(my_array, axis = 1) #Output : [2 3 1 0] print numpy.min(my_array, axis = None) #Output : 0 print numpy.min(my_array) #Output : 0 By default, the axis value is None. The
View Solution →Mean, Var, and Std python
mean The mean tool computes the arithmetic mean along the specified axis. import numpy my_array = numpy.array([ [1, 2], [3, 4] ]) print numpy.mean(my_array, axis = 0) #Output : [ 2. 3.] print numpy.mean(my_array, axis = 1) #Output : [ 1.5 3.5] print numpy.mean(my_array, axis = None) #Output : 2.5 print numpy.mean(my_array) #Output : 2.5 By default, the axis is None. Therefore, it computes the mean of the flattened array. var The var tool
View Solution →Dot and Cross python
dot The dot tool returns the dot product of two arrays. import numpy A = numpy.array([ 1, 2 ]) B = numpy.array([ 3, 4 ]) print numpy.dot(A, B) #Output : 11 cross The cross tool returns the cross product of two arrays. import numpy A = numpy.array([ 1, 2 ]) B = numpy.array([ 3, 4 ]) print numpy.cross(A, B) #Output : -2 Task You are given two arrays A and B. Both have dimensions of N X M. Your task is to compute their matrix product. Input Format
View Solution →