How to find skewness of data using Python
In this tutorial, we are going to learn how to find skewness of data using Python. We can easily find skewness of any data in Python using the following library that is Scipy.stats.
Find skewness of data in Python using Scipy
we simply use this library by
from Scipy.stats import skew
Skewness based on its types
There are three types of skewness :
- Normally Distributed: In this, the skewness is always equated to zero.
Skewness=0
- Positively skewed distribution: In this, A Positively-skewed distribution has a long right tail, that’s why this is also known as right-skewed distribution. the reason behind it, in this value of mode is highest and mean is least which leads to right peak.
Skessness >o
- Negatively skewed distribution: In this, a negatively skewed distribution has a long left tail, that’s why this is also known as left-skewed distribution. the reason behind it, in this value of mode is least and mean is highest just reverse to right-skewed which leads to the left peak.
Skewness<0
The formula to find skewness of data
Skewness =3(Mean- Median)/Standard Deviation
Example: skewness for given data
Input: Any random ten input
from scipy.stats import skew import numpy as np x= np.random.normal(0,5,10) print("X:",x) print("Skewness for data :",skew(x))
Output:
X: [ 5.51964388 -1.69148439 -5.55162585 -5.6901246 2.38861009 2.73400871 3.77918369 -2.30759396 3.67021073 1.48142813] Skewness for data : -0.4625020248485552
Also learn:
Leave a Reply