s” at each locus, which we will specify by a vector <code>p</code>. Specifically, <code>p[r]</code> specifies the frequency of the <code>1</code> allele at locus <code>r</code>.</p>
<p>The following code simulates from this model.</p>
<pre class="r"><code>#&#39; @param n number of samples
#&#39; @param p a vector of allele frequencies
r_haploid_genotypes = function(n,p){
  R = length(p)
  x = matrix(nrow = n, ncol=R)
  for(i in 1:n){
    x[i,] = rbinom(R,rep(1,R),p)
  }
  return(x)
}</code></pre>
<div id=