All problems
Hazard Rate
Problem
Compute the discrete hazard rate per interval: events_i / at_risk_i (0.0 when at_risk is 0).
Return the list of hazards.
Hint
The hazard is the event rate among those still at risk at the start of the interval.
Test cases
case 1
in: [[100,80,60],[10,8,6]]
expected: [0.1,0.1,0.1]
case 2
in: [[50,0,25],[5,0,5]]
expected: [0.1,0,0.2]
case 3
in: [[],[]]
expected: []
Starter codePython
def hazard_rate(at_risk, events):
# Your code here
pass3 test cases · run your code against them in the editor