Hướng dẫn stats.iqr python
Compute the interquartile range of the data along the specified axis. The interquartile range (IQR) is the difference between the 75th and 25th percentile of the data. It is a measure of the dispersion similar to standard deviation or variance, but is much more robust against outliers [2]. The The IQR of an empty array is np.nan. New in version 0.18.0. Parametersxarray_likeInput array or object that can be converted to an array. axisint or sequence of int, optionalAxis along which the range is computed. The default is to compute the IQR for the entire array. rngTwo-element sequence containing floats in range of [0,100] optionalPercentiles over which to compute the range. Each must be between 0 and 100, inclusive. The default is the true IQR: The numerical value of scale will be divided out of the final result. The following string values are recognized:
The default is 1.0. The use of Defines how to handle when input contains nan. The following options are available (default is ‘propagate’): interpolationstr, optional Specifies the interpolation method to use when the percentile boundaries lie between two data points
For NumPy >= 1.22.0, the additional options provided by the If this is set to True, the reduced axes are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the original array x. Returnsiqrscalar or ndarrayIf References 1“Interquartile range” https://en.wikipedia.org/wiki/Interquartile_range 2“Robust measures of scale” https://en.wikipedia.org/wiki/Robust_measures_of_scale 3“Quantile” https://en.wikipedia.org/wiki/Quantile Examples >>> from scipy.stats import iqr >>> x = np.array([[10, 7, 4], [3, 2, 1]]) >>> x array([[10, 7, 4], [ 3, 2, 1]]) >>> iqr(x) 4.0 >>> iqr(x, axis=0) array([ 3.5, 2.5, 1.5]) >>> iqr(x, axis=1) array([ 3., 1.]) >>> iqr(x, axis=1, keepdims=True) array([[ 3.], [ 1.]]) |