Skip to content
DeepForgeby svx
All problems
HardStatisticsst-045

Welch Degrees of Freedom

Problem

Return the Welch-Satterthwaite degrees of freedom (sx^2/nx + sy^2/ny)^2 / ((sx^2/nx)^2/(nx-1) + (sy^2/ny)^2/(ny-1)) using sample variances. Return 0.0 when either sample has fewer than two values or the denominator is zero.

Hint

Square the combined standard error over the sum of the squared components.

Test cases

case 1
in: [[1,2,3,4,5],[2,4,6,8,10]]
expected: 5.882352941176471
case 2
in: [[1,2,3],[4,5,6]]
expected: 4
case 3
in: [[1,1,1],[2,2,2]]
expected: 0
case 4
in: [[1,2,3,4],[5,7,9,11]]
expected: 4.411764705882353
case 5
in: [[5],[1,2,3]]
expected: 0
Starter codePython
def welch_degrees_of_freedom(x, y):
    # Your code here
    pass

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