Skip to content
DeepForgeby svx
All problems
EasyProbabilitypr-101

Branching Process Mean Growth

Problem

For a branching process with offspring distribution probs (probs[k] = P(k offspring)), the mean offspring number is mu = sum(k * probs[k]). Return the expected population size in generation n:

E[Z_n] = mu^n.

Return 0.0 for an empty distribution or negative n.

Hint

Take the expectation of the generation size one step at a time.

Test cases

case 1
in: [[0.5,0.5],3]
expected: 0.125
case 2
in: [[1],5]
expected: 0
case 3
in: [[0.2,0.8],2]
expected: 0.6400000000000001
case 4
in: [[0.1,0.2,0.7],2]
expected: 2.5599999999999996
Starter codePython
def branching_mean_growth(probs, n):
    # Your code here
    pass

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