Skip to content
DeepForgeby svx
All problems
EasyProbabilitypr-196

Hazard From Density

Problem

Hazard rate from a density value and the corresponding survival value:

h = density / survival.

Return 0.0 when survival <= 0.

Hint

The hazard is the instantaneous failure rate among survivors.

Test cases

case 1
in: [0.2,0.8]
expected: 0.25
case 2
in: [0.5,0.5]
expected: 1
case 3
in: [1,0]
expected: 0
case 4
in: [0.1,0.4]
expected: 0.25
Starter codePython
def hazard_from_density(density, survival):
    # Your code here
    pass

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