Skip to content
DeepForgeby svx
All problems
EasyStatisticsst-290

Standardized Mean Difference for Covariates

Problem

Return the standardized mean difference (mean_x - mean_y) / sqrt((var_x + var_y)/2) using population variances. Return 0.0 when either sample has fewer than two values or the pooled standard deviation is zero.

Hint

Scale the mean difference by the pooled standard deviation.

Test cases

case 1
in: [[1,2,3],[3,4,5]]
expected: -2.449489742783178
case 2
in: [[1,2,3,4],[1,2,3,4]]
expected: 0
case 3
in: [[5,5],[1,1]]
expected: 0
case 4
in: [[2,4],[1,3]]
expected: 1
case 5
in: [[1],[1,2]]
expected: 0
Starter codePython
def standardized_mean_difference(x, y):
    # Your code here
    pass

5 test cases · run your code against them in the editor