Skip to content
DeepForgeby svx
All problems
MediumStatisticsst-379

Odds Ratio from Cell Counts

Problem

The sample odds ratio for a 2x2 table is (a * d) / (b * c) with a, b the exposed outcomes and c, d the unexposed outcomes.

Given the four counts, return the odds ratio.

Hint

Cross-multiply the diagonal cells.

Test cases

case 1
in: [10,90,5,95]
expected: 2.111111111111111
case 2
in: [20,30,20,30]
expected: 1
case 3
in: [15,5,5,15]
expected: 9
Starter codePython
def odds_ratio_from_cell_counts(a, b, c, d):
    # Your code here
    pass

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