Skip to content
DeepForgeby svx
All problems
MediumProbabilitypr-416

Hardy Weinberg Genotype Probabilities

Problem

Under Hardy-Weinberg equilibrium with dominant allele frequency p, the genotype probabilities are [p^2, 2 p (1 - p), (1 - p)^2] for the homozygous dominant, heterozygous, and homozygous recessive cases.

Given p, return the three probabilities.

Hint

Square the allele pool expansion (p + (1 - p))^2.

Test cases

case 1
in: [0.5]
expected: [0.25,0.5,0.25]
case 2
in: [0.1]
expected: [0.010000000000000002,0.18000000000000002,0.81]
case 3
in: [0]
expected: [0,0,1]
Starter codePython
def hardy_weinberg_genotype_probabilities(p):
    # Your code here
    pass

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