scipy.stats.skew
We can determine the direction of outliers from skewness. The tail of a distribution curve has a longer right side when there is a positive skew. Accordingly, the distribution curve’s outliers are farther from the mean on the left and closer to it on the right. Skewness just conveys the direction of outliers; it doesn’t provide information on the number of outliers.
Compute the sample skewness of a data set. Skewness should be close to zero for normally distributed data. A skewness value greater than zero indicates that the right tail of a unimodal continuous distribution has more weight.
Syntax:
scipy.stats.skew(a, axis=0, bias=True, nan_policy=’propagate’, *, keepdims=False)
where,
- Input array
- axis ( int , float ) { # optional } – Axis along which statistics are calculated. The default axis is 0.
- bias ( bool ) { # optional } – If False, then the calculations are corrected for statistical bias.
- nan_policy – { ‘propagate’,’raise’,’omit’ } { # optional ) – Handle the NAN inputs.
- keepdims( bool ) ( # optional ) – default is false. broadcast result correctly against the input array.
Return:
- skewness – ndarray
Python3
# importing the stats module from scipy import stats as st # ID input array array = [ 99 , 10 , 30 , 55 , 50 , 0 , 90 , 0 ] # calling the skew function print (st.skew(array)) |
Output:
0.3260023450293658
SciPy – Stats
The scipy.stats is the SciPy sub-package. It is mainly used for probabilistic distributions and statistical operations. There is a wide range of probability functions.
There are three classes:
Class | Description |
rv_continuous | For continuous random variables, we can create specialized distribution subclasses and instances. |
rv_discrete | For discrete random variables, we can create specialized distribution subclasses and instances. |
rv_histogram | generate specific distribution histograms. |
Contact Us