Skip to content
DeepForgeby svx
All problems
MediumStatisticsst-169

Eta Squared from t-Statistic

Problem

Return the eta squared implied by a t statistic: t^2 / (t^2 + df). Return 0.0 when df <= 0.

Hint

This converts a t-test into a proportion of explained variance.

Test cases

case 1
in: [2,10]
expected: 0.2857142857142857
case 2
in: [1,5]
expected: 0.16666666666666666
case 3
in: [0,3]
expected: 0
case 4
in: [3,20]
expected: 0.3103448275862069
case 5
in: [2,0]
expected: 0
Starter codePython
def eta_squared_from_t(t, df):
    # Your code here
    pass

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