Skip to content
DeepForgeby svx
All problems
EasyProbabilitypr-102

Coalescent No-Merge Probability

Problem

In the Wright-Fisher coalescent with population size N, two lineages fail to coalesce in one generation with probability 1 - 1 / (2N). Return the probability they are still separate after generations generations:

P(no merge) = (1 - 1 / (2N))^generations.

Return 0.0 for population <= 0 or negative generations.

Hint

There are 2N gene copies, so a given pair picks the same parent with probability 1 / (2N).

Test cases

case 1
in: [1000,100]
expected: 0.9512175302423342
case 2
in: [1,1]
expected: 0.5
case 3
in: [10,0]
expected: 1
case 4
in: [0,5]
expected: 0
Starter codePython
def coalescent_no_merge_probability(population, generations):
    # Your code here
    pass

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