All problems
Kaplan-Meier Step
Problem
Compute the Kaplan-Meier survival curve: S_i = product over j <= i of (1 - events_j / at_risk_j).
Intervals with at_risk 0 leave the product unchanged. Return the list of survival probabilities.
Hint
The survival curve only drops at intervals where events occur.
Test cases
case 1
in: [[100,80],[10,8]]
expected: [0.9,0.81]
case 2
in: [[10,10,10],[1,1,1]]
expected: [0.9,0.81,0.7290000000000001]
case 3
in: [[5],[5]]
expected: [0]
case 4
in: [[],[]]
expected: []
Starter codePython
def kaplan_meier(at_risk, events):
# Your code here
pass4 test cases · run your code against them in the editor