All problems
Wright-Fisher Drift Variance
Problem
One step of Wright-Fisher drift changes an allele frequency p by an amount with mean 0 and variance:
Var(delta p) = p * (1 - p) / (2N).
Return 0.0 for N <= 0.
Hint
The next count is Binomial(2N, p), so the frequency variance is p(1 - p) / (2N).
Test cases
case 1
in: [0.5,100]
expected: 0.00125
case 2
in: [0.5,10]
expected: 0.0125
case 3
in: [0.2,50]
expected: 0.0016000000000000003
case 4
in: [0.5,0]
expected: 0
Starter codePython
def wright_fisher_drift_variance(p, N):
# Your code here
pass4 test cases · run your code against them in the editor