Computing Cohen's d
Now, using the same comparison of Weight
difference between Sport
s, let's calculate the actual effect size for this comparison. As a reminder, these data are summarized in the boxplot below.
Using the formula seen in the previous video, calculate Cohen's d for the difference in Weight
between each Sport
. Your data is contained in athletes
. pandas
and math
are loaded into your workspace as pd
and ma
.
This exercise is part of the course
Performing Experiments in Python
Exercise instructions
- Create two series, one for the samples from each
Sport
. - Calculate
diff
, the difference between the mean of each sample, andpooledstdev
, the pooled standard deviation. - Calculate Cohen's d and print it.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Create series
athl = ____
swim = ____
# Calculate difference between means and pooled standard deviation
diff = swim.mean() - ____
pooledstdev = ma.sqrt((athl.std()**2 + ____)/2 )
# Calculate Cohen's d
cohend = ____ / pooledstdev
print(____)