All problems
Person-Years Rate
Problem
Return the incidence rate events/person_time per unit of follow-up. Return 0.0 when person_time <= 0.
Hint
The denominator is accumulated time at risk, not the number of people.
Test cases
case 1
in: [120,1000]
expected: 0.12
case 2
in: [0,500]
expected: 0
case 3
in: [50,250]
expected: 0.2
case 4
in: [10,0]
expected: 0
case 5
in: [1,3]
expected: 0.3333333333333333
Starter codePython
def person_years_rate(events, person_time):
# Your code here
pass5 test cases · run your code against them in the editor