Numpy statistical functionsNumpy provides various statistical functions which are used to perform some statistical data analysis. In this section of the tutorial, we will discuss the statistical functions provided by the numpy. Finding the minimum and maximum elements from the arrayThe numpy.amin() and numpy.amax() functions are used to find the minimum and maximum of the array elements along the specified axis respectively. Consider the following example. ExampleOutput: The original array: [[ 2 10 20] [80 43 31] [22 43 10]] The minimum element among the array: 2 The maximum element among the array: 80 The minimum element among the rows of array [ 2 10 10] The maximum element among the rows of array [80 43 31] The minimum element among the columns of array [ 2 31 10] The maximum element among the columns of array [20 80 43] numpy.ptp() functionThe name of the function numpy.ptp() is derived from the name peaktopeak. It is used to return the range of values along an axis. Consider the following example. ExampleOutput: Original array: [[ 2 10 20] [80 43 31] [22 43 10]] ptp value along axis 1: [18 49 33] ptp value along axis 0: [78 33 21] numpy.percentile() functionThe syntax to use the function is given below. It accepts the following parameters.
Consider the following example. ExampleOutput: Array: [[ 2 10 20] [80 43 31] [22 43 10]] Percentile along axis 0 [ 6. 16.6 12. ] Percentile along axis 1 [ 3.6 33.4 12.4] Calculating median, mean, and average of array itemsThe numpy.median() function:Median is defined as the value that is used to separate the higher range of data sample with a lower range of data sample. The function numpy.median() is used to calculate the median of the multidimensional or onedimensional arrays. The numpy.mean() function:The mean can be calculated by adding all the items of the arrays dividing by the number of array elements. We can also mention the axis along which the mean can be calculated. The numpy.average() function:The numpy.average() function is used to find the weighted average along the axis of the multidimensional arrays where their weights are given in another array. Consider the following example. Example
Next TopicNumPy Sorting and Searching
