All problems
Paired t-Statistic
Problem
Return the paired t-statistic mean(d) / (sd(d)/sqrt(n)) for differences d_i = x_i - y_i, using the sample standard deviation. Return 0.0 when n < 2, the lengths differ, or the differences are constant.
Hint
Reduce the paired data to a single list of differences and run a one-sample t-test.
Test cases
case 1
in: [[1,2,3],[0,1,2]]
expected: 0
case 2
in: [[5,7,9],[2,3,4]]
expected: 6.92820323027551
case 3
in: [[10,12,14,16],[8,11,12,15]]
expected: 5.196152422706632
case 4
in: [[1,2],[1,2]]
expected: 0
case 5
in: [[3],[1]]
expected: 0
Starter codePython
def paired_t_statistic(x, y):
# Your code here
pass5 test cases · run your code against them in the editor