Numpy. Amin() and numpy. Amax()
Numpy. Amin() is used to calculate the minimum value of the elements in the array along the specified axis.
Numpy. Amax() is used to calculate the maximum value of elements in an array along the specified axis
a=np.array([1,3,6],[3,4,11],[6,1,4]) Print (NP. Amin (a, 1) ? minimum value of each line Print (NP. Amin (a, 0) × minimum value of each column Print (NP. Amax (a) ා maximum of all elements Print (NP. Amax (a, 1)) ?j the maximum value of each line
[1 3 1]
[1 1 4]
[ 6 11 6]
Used to calculate the difference between the maximum value and the minimum value of an element in an array (maximum minimum value).
- a: Input array
- q: Percentile to calculate
- Axis: the axis along which the percentile is calculated
For an array, if we set its percentile to 20, we can calculate the value of 20% in the array sorting, for example:
Percentail percentage a = np.array([[21, 60, 4], [10, 20, 1]]) Print ('array A: ') print(a) Print ('call percentile() function: ') 50% quantile is the median after sorting in a print(np.percentile(a, 20)) Axis is 0, find on column print(np.percentile(a, 20, axis=0)) Axis is 1, which is on the horizontal line print(np.percentile(a, 20, axis=1)) Keep dimensions the same print(np.percentile(a, 20, axis=1, keepdims=True))
[[21 60 4]
[10 20 1]]
Call the percentile() function:
[12.2 28. 1.6]
Process finished with exit code 0
std=sqrt(mean((x-x.mean()) * * 2)
Where mean ((x-x.mean()) * * 2) refers to the difference between the average value of each sample and that of all samples, i.e. variance, and the standard deviation is the square root of variance.
Other statistical functions
Used to calculate the median of elements in array a
Multiply each value by the corresponding weight, then add the sum to get the total value, and then divide by the total number of units. It is used to calculate the weighted average
Returns the arithmetic average of array elements
The above is the whole content of this article. I hope it will help you in your study, and I hope you can support developepaer more.