Lesson 16 of 18
Skewness
Skewness
Skewness measures the asymmetry of a distribution. It tells you whether the data leans left or right relative to the mean.
Formula
The population skewness is the third standardized moment:
where is the mean and is the population standard deviation (divide by , not ).
Interpretation
- Positive skew (right-tailed): the tail extends to the right; mean > median
- Example: income distributions, waiting times
- Negative skew (left-tailed): the tail extends to the left; mean < median
- Example: exam scores when most students do well
- Zero skew: symmetric distribution (e.g., normal distribution)
Right-skewed: ▓▓▓▓▓▓▓░░░░ (long tail to the right)
Symmetric: ░░░▓▓▓▓▓░░░
Left-skewed: ░░░░▓▓▓▓▓▓▓ (long tail to the left)
Example
data = [0, 0, 3]
mean = 1.0
deviations = [-1, -1, 2]
m3 = ((-1)**3 + (-1)**3 + 2**3) / 3 # = 2.0
std = (2.0) ** 0.5 # population std
skewness = 2.0 / std**3 # = 0.7071
Your Task
Implement skewness(data) that returns the population skewness rounded to 4 decimal places.
Pyodide loading...
Loading...
Click "Run" to execute your code.