First, we have to import Numpy as import numpy as np. To make a Numpy array, you can just use the np.array() function. The aggregate and statistical functions are given below:
- np.sum(m): Used to find out the sum of the given array.
- np.prod(m): Used to find out the product(multiplication) of the values of m.
- np.mean(m): It returns the mean of the input array m.
- np.std(m): It returns the standard deviation of the given input array m.
- np.var(m): Used to find out the variance of the data given in the form of array m.
- np.min(m): It returns the minimum value among the elements of the given array m.
- np.max(m): It returns the maximum value among the elements of the given array m.
- np.argmin(m): It returns the index of the minimum value among the elements of the array m.
- np.argmax(m): It returns the index of the maximum value among the elements of the array m.
- np.median(m): It returns the median of the elements of the array m.
The code using the above all the function is given below:
import numpy as np a=np.array([1,2,3,4,5]) print("a :",a) sum=np.sum(a) print("sum :",sum) product=np.prod(a) print("product :",product) mean=np.mean(a) print("mean :",mean) standard_deviation=np.std(a) print("standard_deviation :",standard_deviation) variance=np.var(a) print("variance :",variance) minimum=np.min(a) print("minimum value :",minimum) maximum=np.max(a) print("maximum value :",maximum) minimum_index=np.argmin(a) print("minimum index :",minimum_index) maximum_index=np.argmax(a) print("maximum-index :",maximum_index) median=np.median(a) print("median :",median)
Output
a : [1 2 3 4 5] sum : 15 product : 120 mean : 3.0 standard_deviation : 1.4142135623730951 variance : 2.0 minimum value : 1 maximum value : 5 minimum index : 0 maximum-index : 4 median : 3.0
0 comments :
Post a Comment
Note: only a member of this blog may post a comment.