All problems
Weibull MTTF Numeric Integral
Problem
Mean time to failure of a Weibull life distribution is the integral of the reliability R(t) = exp(-(t / lam)^k) from 0 to infinity. Approximate it on [0, t_max] with the trapezoid rule using steps intervals. Return 0.0 for invalid arguments.
Hint
For k = 1 the exact MTTF is lam, and for k = 2 it is lam * Gamma(1.5).
Test cases
case 1
in: [1,1,20,1000]
expected: 1.0000333310498923
case 2
in: [2,1,50,2000]
expected: 2.000026041571072
case 3
in: [1,2,10,5000]
expected: 0.8862269254527574
case 4
in: [1,1,0,10]
expected: 0
Starter codePython
import math
def mttf_weibull_integral(lam, k, t_max, steps):
# Your code here
pass4 test cases · run your code against them in the editor