Skip to content
DeepForgeby svx
All problems
EasyProbabilitypr-197

Bathtub Hazard

Problem

Bathtub-shaped hazard rate with infant-mortality, constant and wear-out components:

h(t) = a / t + b + c * t for t > 0.

Return 0.0 for t <= 0 or negative coefficients.

Hint

The three terms capture early failures, random failures and wear-out.

Test cases

case 1
in: [1,0.1,0.2,0.3]
expected: 0.6000000000000001
case 2
in: [2,0.2,0,0.1]
expected: 0.30000000000000004
case 3
in: [0,1,1,1]
expected: 0
case 4
in: [1,0,1,0]
expected: 1
Starter codePython
def bathtub_hazard(t, a, b, c):
    # Your code here
    pass

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