Skip to content
DeepForgeby svx
All problems
MediumProbabilitypr-118

Chernoff Poisson Tail

Problem

Chernoff upper bound for the Poisson tail with rate lam:

P(X >= k) <= e^(-lam) * (e * lam / k)^k.

Return the bound capped at 1.0, 1.0 for k <= 0, and 0.0 when lam <= 0 with k > 0.

Hint

The bound improves quickly as k moves above the mean.

Test cases

case 1
in: [5,10]
expected: 0.14493472568610988
case 2
in: [2,5]
expected: 0.2056758980934416
case 3
in: [1,1]
expected: 1
case 4
in: [5,0]
expected: 1
case 5
in: [0,3]
expected: 0
Starter codePython
import math


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

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