All problems
One-Sample t-Statistic
Problem
Return the one-sample t-statistic (mean - mu0) / (s / sqrt(n)), where s is the sample standard deviation with denominator n - 1. Return 0.0 when n < 2 or the sample variance is zero.
Hint
The denominator is the standard error of the mean.
Test cases
case 1
in: [[1,2,3,4,5],3]
expected: 0
case 2
in: [[1,2,3,4,5],0]
expected: 4.242640687119285
case 3
in: [[10,12,14],12]
expected: 0
case 4
in: [[10,12,14],10]
expected: 1.7320508075688774
case 5
in: [[5],5]
expected: 0
Starter codePython
def t_statistic(data, mu0):
# Your code here
pass5 test cases · run your code against them in the editor