While the t-test or Mann-Whitney U test can tell you whether two distributions are different from each other, it doesn’t tell you the degree to which they are different.
For this purpose, you can calculate Cohen’s D.
Where the pooled standard deviation can be defined as
After calculating Cohen’s D you can gauge the difference via this thumb rule –
- Small effect = 0.2
- Medium Effect = 0.5
- Large Effect = 0.8
Below you can find the code to calculate Cohen’s D in python
import numpy as np
def cohens_d(x,y):
var_x = np.var(x)
var_y = np.var(y)
mean_x = np.mean(x)
mean_y = np.mean(y)
pool_variance = np.sqrt((var_x**2 + var_y**2)/2)
return (mean_x - mean_y)/pool_variance
Write in the comments in case you’ve any questions regarding cohen’s D.
Leave a comment