Skip to content
DeepForgeby svx
All problems
EasyStatisticsst-378

Relative Risk from Counts

Problem

For a 2x2 table with cells a, b (exposed: events, nonevents) and c, d (unexposed), the relative risk is (a / (a + b)) / (c / (c + d)).

Given the four counts, return the relative risk.

Hint

Compare the two event rates.

Test cases

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

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