All problems
Two-Sample Pooled t-Statistic
Problem
Return the pooled two-sample t-statistic (mean_x - mean_y) / (sp*sqrt(1/nx + 1/ny)), where sp^2 = ((nx-1)sx^2 + (ny-1)sy^2)/(nx+ny-2). Return 0.0 when either sample has fewer than two values or the standard error is zero.
Hint
Pool the sums of squares first and divide by nx + ny - 2.
Test cases
case 1
in: [[1,2,3,4,5],[2,4,6,8,10]]
expected: -1.8973665961010275
case 2
in: [[1,2,3],[4,5,6]]
expected: -3.6742346141747673
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: [[1],[2,3]]
expected: 0
Starter codePython
def pooled_t_statistic(x, y):
# Your code here
pass5 test cases · run your code against them in the editor