All problems
Geometric PMF Value
Problem
The geometric pmf for the number of trials until the first success is P(K = k) = (1 - p)^(k - 1) p for k >= 1.
Given p and k, return the probability.
Hint
Fail k - 1 times, then succeed.
Test cases
case 1
in: [0.5,3]
expected: 0.125
case 2
in: [0.1,1]
expected: 0.1
case 3
in: [0.9,2]
expected: 0.08999999999999998
Starter codePython
def geometric_pmf_value(p, k):
# Your code here
pass3 test cases · run your code against them in the editor