Skip to content

Instantly share code, notes, and snippets.

@klmr
Created November 12, 2019 18:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save klmr/281662e3c5d05c4b109b61737ade7e33 to your computer and use it in GitHub Desktop.
Save klmr/281662e3c5d05c4b109b61737ade7e33 to your computer and use it in GitHub Desktop.
Average number of shared alleles between two siblings
n_genes = 20000
n = 100
relatedness = replicate(n, {
child1 = sample(c('mother', 'father'), n_genes, replace = TRUE)
child2 = sample(c('mother', 'father'), n_genes, replace = TRUE)
mean(child1 == child2)
})
mean(relatedness)
# [1] 0.499926
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment