Skip to content
DeepForgeby svx
All problems
HardProbabilitypr-360

Geometric PGF Value

Problem

The probability generating function of the trial-count geometric distribution is G(t) = p t / (1 - (1 - p) t).

Given p and t (with the denominator positive), return G(t).

Hint

The PGF sums p (1-p)^(k-1) t^k over k >= 1.

Test cases

case 1
in: [0.5,1]
expected: 1
case 2
in: [0.2,0.5]
expected: 0.16666666666666669
case 3
in: [0.5,0]
expected: 0
Starter codePython
def geometric_pgf_value(p, t):
    # Your code here
    pass

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