scipy.stats.skew(array, axis=0, bias=True) function calculates the skewness of the data set.
skewness = 0 : normally distributed. skewness > 0 : more weight in the left tail of the distribution. skewness < 0 : more weight in the right tail of the distribution.
Its formula –

Parameters :
array : Input array or object having the elements.
axis : Axis along which the skewness value is to be measured. By default axis = 0.
bias : Bool; calculations are corrected for statistical bias, if set to False.Returns : Skewness value of the data set, along the axis.
Code #1:
# Graph using numpy.linspace() # finding Skewness from scipy.stats import skew import numpy as np import pylab as p x1 = np.linspace( -5, 5, 1000 ) y1 = 1./(np.sqrt(2.*np.pi)) * np.exp( -.5*(x1)**2 ) p.plot(x1, y1, '*') print( '\nSkewness for data : ', skew(y1)) |
Output :
Skewness for data : 1.1108237139164436
Code #2:
# Graph using numpy.linspace() # finding Skewness from scipy.stats import skew import numpy as np import pylab as p x1 = np.linspace( -5, 12, 1000 ) y1 = 1./(np.sqrt(2.*np.pi)) * np.exp( -.5*(x1)**2 ) p.plot(x1, y1, '.') print( '\nSkewness for data : ', skew(y1)) |
Output :
Skewness for data : 1.917677776148478
Code #3: On Random data
# finding Skewness from scipy.stats import skew import numpy as np # random values based on a normal distribution x = np.random.normal(0, 2, 10000) print ("X : \n", x) print('\nSkewness for data : ', skew(x)) |
Output :
X : [ 0.03255323 -6.18574775 -0.58430139 ... 3.22112446 1.16543279 0.84083317] Skewness for data : 0.03248837584866293
Recommended Posts:
- scipy stats.f() | Python
- scipy stats.chi() | Python
- scipy stats.gilbrat() | Python
- scipy stats.gengamma() | Python
- scipy stats.gamma() | Python
- scipy stats.genhalflogistic() | Python
- scipy stats.gausshyper() | Python
- scipy stats.genextreme() | Python
- scipy stats.frechet_l() | Python
- scipy stats.frechet_r() | Python
- scipy stats.foldnorm() | Python
- scipy stats.foldcauchy() | Python
- scipy stats.halfcauchy() | Python
- scipy stats.halfgennorm() | Python
- scipy stats.hypsecant() | Python
- scipy stats.rv_continuous() | Python
- sciPy stats.sem() function | Python
- sciPy stats.hmean() | Python
- scipy stats.halflogistic() | Python
- scipy stats.gumbel_l() | Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Skewness for data : 1.1108237139164436
Skewness for data : 1.917677776148478