Skip to content
DeepForgeby svx
All problems
EasyProbabilitypr-057

Weibull CDF

Problem

Weibull cumulative distribution function with scale lam and shape k:

F(x) = 1 - exp(-(x / lam)^k) for x >= 0, else 0.

Return 0.0 for nonpositive lam or k.

Hint

With k = 1 the Weibull reduces to the exponential distribution.

Test cases

case 1
in: [1,1,1]
expected: 0.6321205588285577
case 2
in: [2,3,2]
expected: 0.6321205588285577
case 3
in: [1,2,3]
expected: 0.9998765901959134
case 4
in: [1,1,-1]
expected: 0
Starter codePython
import math


def weibull_cdf(lam, k, x):
    # Your code here
    pass

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