Skip to content
DeepForgeby svx
All problems
EasyML Fundamentalsml-209

Survival Probability

Problem

Compute the survival probability through the first t intervals: product of (1 - hazard_i).

Return 1.0 for t <= 0; if t exceeds the number of hazards, use all of them.

Hint

Survival is the product of per-interval survival chances.

Test cases

case 1
in: [[0.1,0.2,0.3],2]
expected: 0.7200000000000001
case 2
in: [[0.5],1]
expected: 0.5
case 3
in: [[0.1],0]
expected: 1
case 4
in: [[0.2,0.2],5]
expected: 0.6400000000000001
Starter codePython
def survival_probability(hazards, t):
    # Your code here
    pass

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