Premium problem112. How Good Is the Poisson Approximation?

Medium Locked

Compute the exact Binomial(n,p)\mathrm{Binomial}(n, p) probability of k successes, and the Poisson approximation to it with λ=np\lambda = np. Return the absolute difference.

The approximation is good when n is large and p small, and visibly poor when p is not small. Returning the error rather than either value makes that trade-off the answer.

Input

n = 1000
p = 0.001
k = 1

Output

0.0001840470877805811

Premium problem

This one's part of Premium. Unlock the full Probability track plus every other premium problem on the site.

Implement solve(...)