Skip to content
DeepForgeby svx
All problems
EasyProbabilitypr-015

Exponential CDF

Problem

Exponential cumulative distribution function evaluated at x.

F(x) = 1 - e^(-lam * x) for x >= 0 and 0 otherwise. Return 0.0 for negative lam.

Hint

F(x) is the integral of the density from 0 to x.

Test cases

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


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

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