All problems
CFI Lite
Problem
Return the comparative fit index 1 - max(chi2 - df, 0)/max(chi2_null - df_null, 0), clamped to [0, 1]. Return 0.0 when a degrees-of-freedom value is not positive or the null denominator is not positive.
Hint
CFI compares the fitted model against a baseline independence model.
Test cases
case 1
in: [30,10,200,15]
expected: 0.8918918918918919
case 2
in: [5,10,200,15]
expected: 1
case 3
in: [50,20,60,25]
expected: 0.1428571428571429
case 4
in: [30,0,200,15]
expected: 0
case 5
in: [30,10,10,15]
expected: 0
Starter codePython
def cfi_lite(chi2, df, chi2_null, df_null):
# Your code here
pass5 test cases · run your code against them in the editor