All problems
Welch t-Statistic
Problem
Return the Welch t-statistic (mean_x - mean_y) / sqrt(sx^2/nx + sy^2/ny), where sx^2 and sy^2 are sample variances. Return 0.0 when either sample has fewer than two values or the standard error is zero.
Hint
Unlike the pooled t-statistic, the standard error uses the two sample variances directly.
Test cases
case 1
in: [[1,2,3,4,5],[2,4,6,8,10]]
expected: -1.8973665961010275
case 2
in: [[1,2,3],[1,2,3]]
expected: 0
case 3
in: [[1,1,1],[2,2,2]]
expected: 0
case 4
in: [[10,12,14],[9,11,13]]
expected: 0.6123724356957945
case 5
in: [[5],[1,2,3]]
expected: 0
Starter codePython
def welch_t_statistic(x, y):
# Your code here
pass5 test cases · run your code against them in the editor