All problems
Yule's Q
Problem
Return Yule's Q = (a*d - b*c) / (a*d + b*c) for a 2x2 table. Return 0.0 when the denominator is zero.
Hint
Q is a symmetric measure of 2x2 association ranging from -1 to 1.
Test cases
case 1
in: [10,20,30,40]
expected: -0.2
case 2
in: [10,0,0,10]
expected: 1
case 3
in: [5,5,5,5]
expected: 0
case 4
in: [1,2,3,4]
expected: -0.2
case 5
in: [1,0,1,0]
expected: 0
Starter codePython
def yules_q(a, b, c, d):
# Your code here
pass5 test cases · run your code against them in the editor