All problems
Binomial MGF at Point
Problem
The moment generating function of a binomial(n, p) is (1 - p + p e^t)^n.
Given n, p, and t, return M(t).
Hint
Substitute the Bernoulli MGF into the n-fold product.
Test cases
case 1
in: [10,0.5,0]
expected: 1
case 2
in: [5,0.2,1]
expected: 4.3796667875899775
case 3
in: [3,1,0.5]
expected: 4.481689070338065
Starter codePython
def binomial_mgf_at_point(n, p, t):
# Your code here
pass3 test cases · run your code against them in the editor