Last active
September 15, 2021 07:37
-
-
Save ugo-nama-kun/49e40adc24be0c4c1177c1ea7c0b3130 to your computer and use it in GitHub Desktop.
【統計】Cohen's d の計算方法
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from numpy import std, mean, sqrt | |
#correct if the population S.D. is expected to be equal for the two groups. | |
def cohen_d(x,y): | |
nx = len(x) | |
ny = len(y) | |
dof = nx + ny - 2 | |
return (mean(x) - mean(y)) / sqrt(((nx-1)*std(x, ddof=1) ** 2 + (ny-1)*std(y, ddof=1) ** 2) / dof) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Picked-up from : https://stackoverflow.com/questions/21532471/how-to-calculate-cohens-d-in-python
The detail is explained in Wikipedia: https://en.wikipedia.org/wiki/Effect_size#Cohen's_d
And a nutshell:
